38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
10
.github/ISSUE_TEMPLATE/custom.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/custom.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Custom issue template
|
||||
about: Describe this issue template's purpose here.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
66
.github/workflows/build-and-publish-develop.yaml
vendored
Normal file
66
.github/workflows/build-and-publish-develop.yaml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: SNAPSHOT - Build and Publish Maven Artifacts
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
env:
|
||||
NEXUS_USERNAME: 'edward'
|
||||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_PUBLIC_REPOSITORY_URL: ${{ secrets.MAVEN_PUBLIC_REPOSITORY_URL }}
|
||||
SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }}
|
||||
RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }}
|
||||
|
||||
jobs:
|
||||
build-java:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
packages: write
|
||||
name: Build Java Package and Publish
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v4.2.2
|
||||
if: ${{ hashFiles('**/pom.xml') }}
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: zulu
|
||||
cache: 'maven'
|
||||
- name: maven-settings-xml-action
|
||||
uses: whelk-io/maven-settings-xml-action@v22
|
||||
with:
|
||||
profiles: >
|
||||
[{
|
||||
"id": "homelab",
|
||||
"properties": {
|
||||
"altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}",
|
||||
"altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}"
|
||||
}
|
||||
}]
|
||||
repositories: >
|
||||
[{
|
||||
"id": "maven-public",
|
||||
"url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}",
|
||||
"snapshots": {
|
||||
"enabled": "true"
|
||||
}
|
||||
}]
|
||||
servers: >
|
||||
[{
|
||||
"id": "nexus-snapshot",
|
||||
"username": "${env.NEXUS_USERNAME}",
|
||||
"password": "${env.NEXUS_PASSWORD}"
|
||||
},
|
||||
{
|
||||
"id": "nexus-release",
|
||||
"username": "${env.NEXUS_USERNAME}",
|
||||
"password": "${env.NEXUS_PASSWORD}"
|
||||
}]
|
||||
- name: Maven Publish
|
||||
run: |
|
||||
mvn -B deploy -P homelab
|
||||
80
.github/workflows/build-and-publish-release.yml
vendored
Normal file
80
.github/workflows/build-and-publish-release.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
name: RELEASE - Build and Publish Maven Artifacts
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
NEXUS_USERNAME: 'edward'
|
||||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_PUBLIC_REPOSITORY_URL: ${{ secrets.MAVEN_PUBLIC_REPOSITORY_URL }}
|
||||
SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }}
|
||||
RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }}
|
||||
|
||||
jobs:
|
||||
build-java:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
packages: write
|
||||
name: Build Java Package and Publish
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v4.2.2
|
||||
if: ${{ hashFiles('**/pom.xml') }}
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: zulu
|
||||
cache: 'maven'
|
||||
- name: maven-settings-xml-action
|
||||
uses: whelk-io/maven-settings-xml-action@v22
|
||||
with:
|
||||
profiles: >
|
||||
[{
|
||||
"id": "homelab",
|
||||
"properties": {
|
||||
"altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}",
|
||||
"altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}"
|
||||
}
|
||||
}]
|
||||
repositories: >
|
||||
[{
|
||||
"id": "maven-public",
|
||||
"url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}",
|
||||
"snapshots": {
|
||||
"enabled": "true"
|
||||
}
|
||||
}]
|
||||
servers: >
|
||||
[{
|
||||
"id": "nexus-snapshot",
|
||||
"username": "${env.NEXUS_USERNAME}",
|
||||
"password": "${env.NEXUS_PASSWORD}"
|
||||
},
|
||||
{
|
||||
"id": "nexus-release",
|
||||
"username": "${env.NEXUS_USERNAME}",
|
||||
"password": "${env.NEXUS_PASSWORD}"
|
||||
}]
|
||||
- name: Config Git
|
||||
run: |
|
||||
git config --global user.email "edward@cheng.sydney"
|
||||
git config --global user.name "3dwardch3ng"
|
||||
git config --global core.autocrlf input
|
||||
- name: Start release
|
||||
run: |
|
||||
mvn gitflow:release-start -B -DpushRemote=true -DallowSnapshots=true -P homelab
|
||||
- name: Maven Publish
|
||||
run: |
|
||||
mvn -B deploy -P homelab
|
||||
- name: Finish release
|
||||
env:
|
||||
GITHUB_ACTOR: 3dwardch3ng
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
run: |
|
||||
mvn gitflow:release-finish -B -DpushRemote=true -DallowSnapshots=true -P homelab
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,3 +22,5 @@
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
/.idea/
|
||||
65
.mvn/settings.xml
Normal file
65
.mvn/settings.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>homelab</id>
|
||||
<properties>
|
||||
<altSnapshotDeploymentRepository>nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}</altSnapshotDeploymentRepository>
|
||||
<altReleaseDeploymentRepository>nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}</altReleaseDeploymentRepository>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus-snapshot</id>
|
||||
<name>Home Lab Nexus Snapshot</name>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>warn</checksumPolicy>
|
||||
</snapshots>
|
||||
<url>${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nexus-release</id>
|
||||
<name>Home Lab Nexus Release</name>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>warn</checksumPolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<url>${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>nexus-central</id>
|
||||
<name>Home Lab Nexus Maven Central</name>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<checksumPolicy>warn</checksumPolicy>
|
||||
</releases>
|
||||
<url>${env.NEXUS_CENTRAL_REPOSITORY_URL}</url>
|
||||
<layout>default</layout>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<servers>
|
||||
<server>
|
||||
<id>nexus-snapshot</id>
|
||||
<username>${env.NEXUS_USERNAME}</username>
|
||||
<password>${env.NEXUS_PASSWORD}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>nexus-release</id>
|
||||
<username>${env.NEXUS_USERNAME}</username>
|
||||
<password>${env.NEXUS_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
3
CODEOWNERS
Normal file
3
CODEOWNERS
Normal file
@@ -0,0 +1,3 @@
|
||||
# Repository CODEOWNERS
|
||||
|
||||
@3dwardCh3nG
|
||||
128
CODE_OF_CONDUCT.md
Normal file
128
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
edward@cheng.sydney.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
28
SECURITY.md
Normal file
28
SECURITY.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
|---------|--------------------|
|
||||
| v1.x.x | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you find a security vulnerability affecting any of our supported projects, please
|
||||
email [edward@cheng.sydney](mailto:edward@cheng.sydney), rather than opening a public issue on GitHub. After receiving
|
||||
the initial report, we will endeavor to keep you informed of the progress towards a fix and full announcement. We may
|
||||
ask you for additional information. You are also welcome to propose a patch or solution.
|
||||
|
||||
Report security bugs in third-party modules to the person or team maintaining the module.
|
||||
|
||||
## Coordinated Disclosure
|
||||
|
||||
We aim to patch confirmed vulnerabilities within 30 days or less, disclosing the details of those vulnerabilities when a
|
||||
patch is published. We ask that you refrain from sharing your report with others while we work on our patch.
|
||||
|
||||
We may want to coordinate an advisory with you to be published simultaneously with the patch, but you are also welcome
|
||||
to self-disclose after 90 days if you prefer. We will never publish information about you or our communications with you
|
||||
without your permission.
|
||||
26
configuration/pom.xml
Normal file
26
configuration/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-microservice-commons</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ec-microservice-commons-configuration</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,26 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import sydney.cheng.microservice.commons.configuration.properties.auth.SecurityProperties;
|
||||
import sydney.cheng.microservice.commons.configuration.properties.database.DatabaseProperties;
|
||||
|
||||
@Data
|
||||
@ConfigurationPropertiesScan(basePackages = {"sydney.cheng.**.properties"})
|
||||
@ConfigurationProperties("app")
|
||||
@Configuration
|
||||
public class AppConfiguration {
|
||||
private ApplicationConfiguration application;
|
||||
private SecurityProperties security;
|
||||
private DatabaseProperties database;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public static class ApplicationConfiguration {
|
||||
private String deploymentTarget;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.auth;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ConfigurationProperties(prefix = "app.security.cors")
|
||||
public class CorsProperties {
|
||||
private String allowedUrls;
|
||||
private String allowedOrigins;
|
||||
private List<String> allowedHeaders;
|
||||
private List<String> allowedMethods;
|
||||
private long allowedMaxAge = 3600;
|
||||
private boolean allowCredentials = true;
|
||||
|
||||
public List<String> getAllowedUrlList() {
|
||||
return Arrays.asList(allowedUrls.split(","));
|
||||
}
|
||||
|
||||
public List<String> getAllowedOriginList() {
|
||||
return Arrays.asList(allowedOrigins.split(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.auth;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ConfigurationProperties(prefix = "app.security.oauth2")
|
||||
public class OAuth2Properties {
|
||||
private RemoteTokenCheckProperties remoteTokenCheck;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class RemoteTokenCheckProperties {
|
||||
String checkTokenUrl;
|
||||
String clientId;
|
||||
String clientSecret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.auth;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties("app.security")
|
||||
public class SecurityProperties {
|
||||
private UrlProperties url;
|
||||
private CorsProperties cors;
|
||||
private OAuth2Properties oauth2;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.auth;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "app.security.url")
|
||||
public class UrlProperties {
|
||||
private String frontend;
|
||||
private String backend;
|
||||
private String gateway;
|
||||
private String frontendDefaultLogin;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Profile("database")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DataSourceProperties extends org.springframework.boot.autoconfigure.jdbc.DataSourceProperties implements Serializable {
|
||||
private HikariDataSourceProperties hikari;
|
||||
|
||||
public DataSourceProperties() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Profile("database")
|
||||
@Data
|
||||
public class DatabaseNodeProperties implements Serializable {
|
||||
DataSourceProperties datasource;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Profile("database")
|
||||
@Data
|
||||
@PropertySource("classpath:application.yml")
|
||||
@ConfigurationProperties(prefix = "app.database")
|
||||
public class DatabaseProperties {
|
||||
EntityManagerProperties entityManager;
|
||||
JpaProperties jpa;
|
||||
DatabaseNodeProperties master;
|
||||
DatabaseNodeProperties replica;
|
||||
|
||||
@Data
|
||||
public static class EntityManagerProperties implements Serializable {
|
||||
String packages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
@Profile(value = {"database & hikari"})
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class HikariDataSourceProperties extends HikariConfig implements Serializable {
|
||||
private String urlPrefix;
|
||||
|
||||
public HikariDataSourceProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HikariDataSourceProperties(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public HikariDataSourceProperties(String propertyFileName) {
|
||||
super(propertyFileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Profile(value = {"database & hikari"})
|
||||
@ConfigurationProperties("app.database.primary.datasource.hikari")
|
||||
public class PrimaryHikariDataSourceProperties extends HikariDataSourceProperties {
|
||||
public PrimaryHikariDataSourceProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrimaryHikariDataSourceProperties(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public PrimaryHikariDataSourceProperties(String propertyFileName) {
|
||||
super(propertyFileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package sydney.cheng.microservice.commons.configuration.properties.database;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Profile(value = {"database & hikari"})
|
||||
@ConfigurationProperties("app.database.replica.datasource.hikari")
|
||||
public class ReplicaHikariDataSourceProperties extends HikariDataSourceProperties {
|
||||
public ReplicaHikariDataSourceProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ReplicaHikariDataSourceProperties(String propertyFileName) {
|
||||
super(propertyFileName);
|
||||
}
|
||||
|
||||
public ReplicaHikariDataSourceProperties(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
}
|
||||
36
database/pom.xml
Normal file
36
database/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-microservice-commons</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ec-microservice-commons-database</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-microservice-commons-configuration</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>${caffeine.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
package sydney.cheng.microservice.commons.database.annotation;
|
||||
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Profile("database")
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Transactional("ecTransactionManager")
|
||||
public @interface DatabaseTransactional {
|
||||
boolean readOnly() default false;
|
||||
|
||||
Propagation propagation() default Propagation.REQUIRED;
|
||||
|
||||
Class<? extends Throwable>[] noRollbackFor() default {};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package sydney.cheng.microservice.commons.database.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ReadOnlyConnection {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package sydney.cheng.microservice.commons.database.annotation;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
import sydney.cheng.microservice.commons.database.constant.DbType;
|
||||
import sydney.cheng.microservice.commons.database.datasource.DbContextHolder;
|
||||
|
||||
@Aspect
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Component
|
||||
public class ReadOnlyConnectionInterceptor implements Ordered {
|
||||
private int order;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
@Value("20")
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle interceptor for any public method execution
|
||||
*/
|
||||
@Pointcut(value = "execution(public * *(..))")
|
||||
public void anyPublicMethod() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Around("@annotation(readOnlyConnection)")
|
||||
public Object proceed(ProceedingJoinPoint pjp, ReadOnlyConnection readOnlyConnection) throws Throwable {
|
||||
try {
|
||||
DbContextHolder.setDbType(DbType.REPLICA);
|
||||
Object result = pjp.proceed();
|
||||
DbContextHolder.clearDbType();
|
||||
return result;
|
||||
} finally {
|
||||
// restore state
|
||||
DbContextHolder.clearDbType();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package sydney.cheng.microservice.commons.database.config;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
public class CacheManagerConfiguration {
|
||||
@Bean
|
||||
public Caffeine<Object, Object> caffeineConfig() {
|
||||
return Caffeine.newBuilder().expireAfterWrite(12, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(Caffeine<Object, Object> caffeine) {
|
||||
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
|
||||
caffeineCacheManager.setCaffeine(caffeine);
|
||||
return caffeineCacheManager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package sydney.cheng.microservice.commons.database.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import sydney.cheng.microservice.commons.configuration.properties.database.PrimaryHikariDataSourceProperties;
|
||||
import sydney.cheng.microservice.commons.configuration.properties.database.ReplicaHikariDataSourceProperties;
|
||||
import sydney.cheng.microservice.commons.database.constant.DbType;
|
||||
import sydney.cheng.microservice.commons.database.datasource.RoutingDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Map;
|
||||
|
||||
import static sydney.cheng.microservice.commons.database.constant.DatabaseBeanConstant.*;
|
||||
|
||||
@Profile(value = {"database & hikari"})
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
|
||||
@Configuration
|
||||
public class HikariDataSourceConfiguration {
|
||||
private final PrimaryHikariDataSourceProperties primaryHikariDataSourceProperties;
|
||||
private final ReplicaHikariDataSourceProperties replicaHikariDataSourceProperties;
|
||||
|
||||
@Bean(name = PRIMARY_DS_BEAN_NAME)
|
||||
public DataSource primaryDataSource() {
|
||||
if (this.primaryHikariDataSourceProperties == null) throw new AssertionError();
|
||||
this.primaryHikariDataSourceProperties.setPoolName(PRIMARY_DS_BEAN_NAME);
|
||||
return new HikariDataSource(this.primaryHikariDataSourceProperties);
|
||||
}
|
||||
|
||||
@Bean(name = REPLICA_DS_BEAN_NAME)
|
||||
public DataSource replicaDataSource() {
|
||||
if (this.replicaHikariDataSourceProperties == null) throw new AssertionError();
|
||||
this.replicaHikariDataSourceProperties.setPoolName(REPLICA_DS_BEAN_NAME);
|
||||
return new HikariDataSource(this.replicaHikariDataSourceProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure data source routing for MRCENTRAL.
|
||||
*
|
||||
* @return data source
|
||||
* @see RoutingDataSource
|
||||
*/
|
||||
@Bean(name = {"dataSource", DS_BEAN_NAME})
|
||||
public DataSource centralDataSource() {
|
||||
RoutingDataSource rds = new RoutingDataSource();
|
||||
rds.setTargetDataSources(Map
|
||||
.of(DbType.PRIMARY, this.primaryDataSource(), DbType.REPLICA, this.replicaDataSource()));
|
||||
rds.setDefaultTargetDataSource(this.primaryDataSource());
|
||||
return rds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package sydney.cheng.microservice.commons.database.config;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.hibernate5.SpringBeanContainer;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.JpaVendorAdapter;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import sydney.cheng.microservice.commons.configuration.properties.database.DatabaseProperties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static sydney.cheng.microservice.commons.database.constant.DatabaseBeanConstant.*;
|
||||
|
||||
@Profile(value = {"database & hikari"})
|
||||
@Configuration
|
||||
@EnableJpaRepositories(
|
||||
basePackages = "sydney.cheng.**.repository",
|
||||
entityManagerFactoryRef = "entityManagerFactory",
|
||||
transactionManagerRef = "transactionManager"
|
||||
)
|
||||
public class JPAPersistenceConfiguration {
|
||||
private final ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private final DatabaseProperties databaseProperties;
|
||||
|
||||
public JPAPersistenceConfiguration(
|
||||
ConfigurableListableBeanFactory beanFactory,
|
||||
DatabaseProperties databaseProperties
|
||||
) {
|
||||
this.beanFactory = beanFactory;
|
||||
this.databaseProperties = databaseProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier(DS_BEAN_NAME) DataSource dataSource) {
|
||||
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
|
||||
em.setPersistenceUnitName("persistence-unit");
|
||||
em.setPackagesToScan(this.databaseProperties.getEntityManager().getPackages());
|
||||
em.setDataSource(dataSource);
|
||||
|
||||
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
em.setJpaVendorAdapter(vendorAdapter);
|
||||
|
||||
Map<String, Object> properties = new HashMap<>(this.databaseProperties.getJpa().getProperties());
|
||||
properties.put(AvailableSettings.PHYSICAL_NAMING_STRATEGY, "org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy");
|
||||
properties.put(AvailableSettings.IMPLICIT_NAMING_STRATEGY, "org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy");
|
||||
properties.put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(this.beanFactory));
|
||||
em.setJpaPropertyMap(properties);
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JpaTransactionManager transactionManager(@Qualifier("entityManagerFactory") EntityManagerFactory emf) {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
transactionManager.setEntityManagerFactory(emf);
|
||||
return transactionManager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package sydney.cheng.microservice.commons.database.constant;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
|
||||
public class DatabaseBeanConstant {
|
||||
public static final String DS_BEAN_NAME = "databaseDataSource";
|
||||
public static final String PRIMARY_DS_BEAN_NAME = "databaseDataSourcePrimary";
|
||||
public static final String REPLICA_DS_BEAN_NAME = "databaseDataSourceReplica";
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package sydney.cheng.microservice.commons.database.constant;
|
||||
|
||||
public enum DbType {
|
||||
PRIMARY, REPLICA
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package sydney.cheng.microservice.commons.database.datasource;
|
||||
|
||||
import sydney.cheng.microservice.commons.database.constant.DbType;
|
||||
|
||||
public class DbContextHolder {
|
||||
|
||||
private static final ThreadLocal<DbType> contextHolder = new ThreadLocal<>();
|
||||
|
||||
private DbContextHolder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static DbType getDbType() {
|
||||
return contextHolder.get();
|
||||
}
|
||||
|
||||
public static void setDbType(DbType dbType) {
|
||||
if (dbType == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
contextHolder.set(dbType);
|
||||
}
|
||||
|
||||
public static void clearDbType() {
|
||||
contextHolder.remove();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package sydney.cheng.microservice.commons.database.datasource;
|
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||
|
||||
public class RoutingDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
@Override
|
||||
protected Object determineCurrentLookupKey() {
|
||||
return DbContextHolder.getDbType();
|
||||
}
|
||||
}
|
||||
26
entity/pom.xml
Normal file
26
entity/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-microservice-commons</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ec-microservice-commons-entity</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
31
entity/src/main/java/sydney/cheng/entity/AbstractUser.java
Normal file
31
entity/src/main/java/sydney/cheng/entity/AbstractUser.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package sydney.cheng.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.UuidGenerator;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public abstract class AbstractUser implements Serializable {
|
||||
@Id
|
||||
@UuidGenerator(style = UuidGenerator.Style.TIME)
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column(name = "username", nullable = false)
|
||||
private String username;
|
||||
|
||||
@Column(name = "email", nullable = false, unique = true)
|
||||
private String email;
|
||||
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
}
|
||||
105
pom.xml
Normal file
105
pom.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-super-pom</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ec-microservice-commons</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://www.opensource.org/licenses/mit-license.php</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Edward Cheng</name>
|
||||
<email>edward@cheng.sydney</email>
|
||||
<organization>cheng.sydney</organization>
|
||||
<organizationUrl>https://3dwardch3ng.github.io/</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/3dwardch3ng/ec-microservice-commons.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:3dwardch3ng/ec-microservice-commons.git</developerConnection>
|
||||
<url>https://github.com/3dwardch3ng/ec-microservice-commons/tree/main</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/3dwardch3ng/ec-microservice-commons/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<modules>
|
||||
<module>swagger</module>
|
||||
<module>entity</module>
|
||||
<module>configuration</module>
|
||||
<module>database</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Dependency Versions -->
|
||||
<spring-context-support.version>6.1.12</spring-context-support.version>
|
||||
<springdoc-openapi-starter-common.version>2.6.0</springdoc-openapi-starter-common.version>
|
||||
<atomikos.version>6.0.0</atomikos.version>
|
||||
<caffeine.version>3.1.8</caffeine.version>
|
||||
<!-- Sonar Properties -->
|
||||
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
|
||||
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
|
||||
<sonar.jacoco.xmlReportPath>${project.basedir}/../target/site/jacoco/jacoco.xml</sonar.jacoco.xmlReportPath>
|
||||
<sonar.language>java</sonar.language>
|
||||
<sonar.coverage.exclusions>**/config/*</sonar.coverage.exclusions>
|
||||
<sonar.organization>3dwardch3ng</sonar.organization>
|
||||
<sonar.host.url>https://sonarqube.cluster.edward.sydney</sonar.host.url>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
16
renovate.json
Normal file
16
renovate.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"local>3dwardch3ng/renovate-config"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchDatasources": ["maven"],
|
||||
"registryUrls": [
|
||||
"https://nexus.cluster.edward.sydney/repository/maven-releases",
|
||||
"https://nexus.cluster.edward.sydney/repository/maven-snapshots",
|
||||
"https://repo.maven.apache.org/maven2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
30
swagger/pom.xml
Normal file
30
swagger/pom.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>sydney.cheng</groupId>
|
||||
<artifactId>ec-microservice-commons</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cheng.edward</groupId>
|
||||
<artifactId>ec-microservice-commons-swagger</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-common</artifactId>
|
||||
<version>${springdoc-openapi-starter-common.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package cheng.edward.microservice.commons.swagger.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@OpenAPIDefinition(info = @Info(title = "MediRecords Secure Message API", version = "v1"))
|
||||
@SecurityScheme(
|
||||
name = "Authentication Token",
|
||||
type = SecuritySchemeType.HTTP,
|
||||
scheme = "bearer"
|
||||
)
|
||||
public class SwaggerConfiguration {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cheng.edward.microservice.commons.swagger.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
|
||||
@SecurityRequirement(name = "Authentication Token")
|
||||
public interface SecuredController {
|
||||
}
|
||||
Reference in New Issue
Block a user