diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..a2331cb --- /dev/null +++ b/.env.docker @@ -0,0 +1,15 @@ +POSTGRES_DB=zfgc_dev +POSTGRES_USER=postgres +POSTGRES_PASSWORD=123456 + +SPRING_DATASOURCE_USERNAME=postgres +SPRING_DATASOURCE_PASSWORD=123456 +MBG_JBDC_USERNAME=postgres +MBG_JDBC_PASSWORD=123456 + +PGADMIN_DATABASE_URI=postgres://postgres:123456@zfgbb_postgresql:5432/zfgc_dev +SPRING_DATASOURCE_URL=jdbc:postgresql://zfgbb_postgresql:5432/zfgc_dev +MBG_JDBC_URL=jdbc:postgresql://zfgbb_postgresql:5432/zfgc_dev + +ZFGBB_CONTENT_PATH=/usr/local/tomcat/webapps/content +ZFGBB_CONTENT_IMAGES=/usr/local/tomcat/webapps/content/images \ No newline at end of file diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..0f47db7 --- /dev/null +++ b/.env.local @@ -0,0 +1,11 @@ +ZFGBB_DATABASE=zfgc_dev +ZFGBB_USER=zfgbb_user +ZFGBB_USER_PASSWORD=123456 + +SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/zfgc_dev +SPRING_DATASOURCE_USERNAME=zfgbb_user +SPRING_DATASOURCE_PASSWORD=123456 + +MBG_JDBC_URL=jdbc:postgresql://localhost:5432/zfgc_dev +MBG_JBDC_USERNAME=zfgbb_user +MBG_JDBC_PASSWORD=123456 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..526c8a3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 273fff0..8f40fb9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,11 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - package-ecosystem: "maven" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "weekly" +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "maven" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b3ec64..00c2423 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,20 @@ -name: CI -on: - pull_request: -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - java-version: [17] - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java-version}} for x64 - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java-version }} - distribution: 'temurin' - architecture: x64 - cache: maven - - name: Build with Maven +name: CI +on: + pull_request: +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [17] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java-version}} for x64 + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + architecture: x64 + cache: maven + - name: Build with Maven run: mvn clean compile package -Dmaven.test.skip=true \ No newline at end of file diff --git a/.github/workflows/k8s-deploy.yml b/.github/workflows/k8s-deploy.yml new file mode 100644 index 0000000..7f99d48 --- /dev/null +++ b/.github/workflows/k8s-deploy.yml @@ -0,0 +1,31 @@ +# name: Kubernetes Deployment + +# on: +# push: +# branches: +# - main + +# jobs: +# deploy: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set up Kubernetes CLI +# uses: azure/setup-kubectl@v1 +# with: +# version: 'v1.21.0' +# - name: Create MySQL and PostgreSQL Secrets +# run: | +# echo "$MYSQL_PASSWORD" | base64 | kubectl create secret generic mysql-secret \ +# --from-literal=password=- \ +# --dry-run=client -o yaml | kubectl apply -f - +# echo "$POSTGRES_PASSWORD" | base64 | kubectl create secret generic postgres-secret \ +# --from-literal=password=- \ +# --dry-run=client -o yaml | kubectl apply -f - +# env: +# MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} +# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} +# - name: Deploy +# run: | +# export $(cat kustomize.env | xargs) # Load and export env vars +# kustomize build base | kubectl apply -f - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 549e00a..c7392f5 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,13 @@ build/ !**/src/main/**/build/ !**/src/test/**/build/ -### VS Code ### -.vscode/ +### Build Files ### +dist/ + +### Environment Files ### +**/.env +**/.env.secret +*.env +*.env.secret +!.env.docker +!.env.local \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..05c9a94 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack", + "vmware.vscode-boot-dev-pack" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..28fee7d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Debug Backend", + "request": "launch", + "mainClass": "com.zfgc.zfgbb.ZfgbbApplication", + "projectName": "zfgbb", + "envFile": "${workspaceFolder}/.env.local", + "env": { + "ZFGBB_CONTENT_PATH": "${workspaceFolder}/backend-assets", + "ZFGBB_CONTENT_IMAGES": "${workspaceFolder}/backend-assets" + } + }, + { + "type": "java", + "name": "Debug Backend (docker)", + "request": "launch", + "mainClass": "com.zfgc.zfgbb.ZfgbbApplication", + "projectName": "zfgbb", + "envFile": "${workspaceFolder}/.env.docker" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..25d5063 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive", + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0492ee9..aefcc3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,32 @@ -FROM maven:3.9-eclipse-temurin-17 AS build - -RUN mkdir -p /usr/src/zfgcbb -COPY . /usr/src/zfgcbb - -WORKDIR /usr/src/zfgcbb - -RUN mvn clean compile package -Dmaven.test.skip=true - -FROM postgres:16 AS database - -#RUN echo "CREATE DATABASE zfgcbb; CREATE USER $SPRING_DATASOURCE_USERNAME; GRANT ALL PRIVILEGES ON DATABASE zfgcbb TO $SPRING_DATASOURCE_USERNAME;" > /docker-entrypoint-initdb.d/init.sql - -FROM tomcat:jre17-temurin-jammy AS deploy - -COPY --from=build /usr/src/zfgcbb/target/*.war /usr/local/tomcat/webapps/ - -EXPOSE 8080 - -CMD ["catalina.sh", "run"] \ No newline at end of file +# FROM maven:3.9-eclipse-temurin-17 AS base + +# WORKDIR /usr/src +# ADD ./mvn* ./ +# ADD ./pom.xml ./ +# RUN mvn install -Dmaven.test.skip=true + +# # Yeah, this is ugly. Sue me. +# CMD ["mvn", "install", "-Dmaven.test.skip=true"] + +FROM maven:3.9-eclipse-temurin-17 AS build +WORKDIR /usr/src +ADD ./mvn* ./ +ADD ./pom.xml ./ +# RUN mvn install -Dmaven.test.skip=true + +ADD ./src ./src +RUN mvn clean compile package -Dmaven.test.skip=true + +# FIXME: This image should be switched to gcr.io/distroless/java-base-debian12 because it is much smaller. For now, this will work. +FROM tomcat:jre17-temurin-jammy AS deploy + +COPY --from=build /usr/src/target/*.war /usr/local/tomcat/webapps/ +RUN mkdir -p /usr/local/tomcat/webapps/content/images + +EXPOSE ${ZFGBB_BACKEND_PORT:-8080} +CMD ["catalina.sh", "run"] + +FROM postgres:16 AS database +ADD ./scripts/sql/provisioning/1-zfgbb.initialize-database.sh /docker-entrypoint-initdb.d/1-zfgbb.initialize-database.sh +# We exclude .sql from the file name so that it gets ignored by the init script. +ADD ./scripts/sql/provisioning/2-provision-database.sql /docker-entrypoint-initdb.d/2-provision-database \ No newline at end of file diff --git a/README.md b/README.md index e89885d..f3b3417 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,119 @@ -Java 17 -maven clean install -Dmaven.test.skip=true \ No newline at end of file +# ZFGBB Backend + +Bringin back the Drama Llama from the dead! + +[![CI](https://github.com/ZFGCCP/ZFGCBB/actions/workflows/ci.yml/badge.svg)](https://github.com/ZFGCCP/ZFGCBB/actions/workflows/ci.yml) + +## Table of Contents + +- [ZFGBB Backend](#zfgbb-backend) + - [Table of Contents](#table-of-contents) + - [Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Setup](#setup) + - [Developing with an IDE](#developing-with-an-ide) + - [Visual Studio Code](#visual-studio-code) + - [Eclipse](#eclipse) + - [Developing Standalone](#developing-standalone) + - [Building](#building) + - [Running Tests](#running-tests) + - [Running MyBatis Generator](#running-mybatis-generator) + - [IaC (Infrastructure as Code)](#iac-infrastructure-as-code) + - [License](#license) + +## Getting Started + +### Prerequisites + +- [Git Bash](https://git-scm.com/downloads) +- [Docker/Docker-Compose](https://docs.docker.com/get-docker/) +- [Java 17](https://www.oracle.com/java/technologies/downloads/) +- [Maven](https://maven.apache.org/) +- If running locally + - [PostgreSQL](https://www.postgresql.org/download/) + - [Tomcat](https://tomcat.apache.org/) + +#### Setup + +To use the automatic setup script to download and install dependencies, make sure [Git Bash](https://git-scm.com/downloads) is installed. This script currently supports Windows, macOS, and Linux. + +This repository provides a [setup script](./scripts/development/setup.sh). It will automatically detect your environment and prompt you to install dependencies. For Linux, only two kinds of distros are handled for installing packages (Arch and Ubuntu). For any other Linux distro, the script will just check the presence of dependencies. + +Using the script can be done by invoking the following command. + +```bash +./scripts/development/setup.sh +``` + +### Developing with an IDE + +Opening the project in Eclipse or Visual Studio Code is recommended. + +Stand up the database using the following command. + +```bash +docker-compose up -d postgresql pgadmin +``` + +You can access pgadmin at `http://0.0.0.0:5050`. + +#### Visual Studio Code + +The [vscode settings](./.vscode/settings.json) provides a basic setup for developing with VS Code. + +The following build actions are available: + +- `Debug Backend`: Runs the backend in debug mode, using `.env.local` as the environment file. NOTE: Docker should resolve just fine, but if not you can use the (Docker) variant of this action. +- `Debug Backend (Docker)`: Runs the backend in debug mode, using `.env.docker` as the environment file. + +#### Eclipse + +Eclipse will respect the applications.properties file, so you can use that to configure the application. + +### Developing Standalone + +To run the application in development mode, run the following command: + +```bash +mvn clean run package -Dmaven.test.skip=true +``` + +This will start the application in development mode, and you can access it at `http://0.0.0.0:8080`. + +### Building + +To build the application, run the following command: + +```bash +mvn clean compile package -Dmaven.test.skip=true +``` + +This will create a `.war` file in the `target` directory. + +### Running Tests + +To run the tests, run the following command: + +```bash +mvn test +``` + +This will run all the tests in the [src/test](src/test) directory. + +### Running MyBatis Generator + +To run the MyBatis generator, run the following command: + +```bash +nvm mybatis-generator:generate +``` + +This will generate the MyBatis mappers and Java models based on the database schema. + +## IaC (Infrastructure as Code) + +We implement a [Kubernetes Project](./iac/) to deploy the application to a Kubernetes cluster. This also contains configuration for the legacy zfgc.com environment under the `old-skool` service. More details can be found in the [IaC README](./iac/). + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/docker-compose.yml b/docker-compose.yml index 0fafaa3..70ca178 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,42 +1,76 @@ -services: - postgresql: - build: - context: . - dockerfile: Dockerfile - target: database - container_name: zfgcbb_postgresql - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=123456 - - POSTGRES_DB=zfgcbb - ports: - - "5432:5432" - volumes: - - data:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready" ,"-d", "zfgcbb"] - interval: 30s - timeout: 60s - retries: 5 - start_period: 80s - - zfgcbb: - build: - context: . - dockerfile: Dockerfile - target: deploy - ports: - - "8080:8080" - volumes: - - logs:/usr/src/app/logs - environment: - - SPRING_DATASOURCE_URL=jdbc:postgresql://zfgcbb_postgresql:5432/zfgcbb - - SPRING_DATASOURCE_USERNAME=postgres - - SPRING_DATASOURCE_PASSWORD=123456 - - SPRING_JPA_HIBERNATE_DDL_AUTO=create-drop - depends_on: - - postgresql - -volumes: - data: - logs: +name: zfgbb +services: + postgresql: + container_name: zfgbb_postgresql + # hostname: zfgbb_postgresql + build: + context: . + dockerfile: Dockerfile + target: database + env_file: + - .env.local + - .env.docker + ports: + - "${POSTGRES_PORT:-5432}:${POSTGRES_PORT:-5432}" + networks: + - zfgbb + volumes: + - data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER:-postgres} -d ${ZFGBB_DATABASE:-zfgc_dev}'"] + interval: 30s + timeout: 60s + retries: 5 + start_period: 80s + extra_hosts: + - "host.docker.internal:host-gateway" + + pgadmin: + container_name: zfgbb_pgadmin + # hostname: zfgbb_pgadmin + image: dpage/pgadmin4:8.14.0 + environment: + PGADMIN_LISTEN_PORT: ${PGADMIN_PORT:-5050} + PGADMIN_DEFAULT_EMAIL: admin@zfgc.com + PGADMIN_DEFAULT_PASSWORD: ${POSTGRES_PASSWORD:-123456} + CONFIG_DATABASE_URI: ${PGADMIN_DATABASE_URI:-postgres://postgres:123456@zfgbb_postgresql:5432/zfgc_dev} + ports: + - "${PGADMIN_PORT:-5050}:${PGADMIN_PORT:-5050}" + networks: + - zfgbb + volumes: + - pgadmin:/var/lib/pgadmin + depends_on: + - postgresql + extra_hosts: + - "host.docker.internal:host-gateway" + + api: + container_name: zfgbb_api + # hostname: zfgbb_api + build: + context: . + dockerfile: Dockerfile + target: deploy + ports: + - "${ZFGBB_BACKEND_PORT:-8080}:${ZFGBB_BACKEND_PORT:-8080}" + networks: + - zfgbb + volumes: + - logs:/usr/src/app/logs + env_file: + - .env.local + - .env.docker + depends_on: + - postgresql + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + pgadmin: + data: + logs: + +networks: + zfgbb: + # driver: bridge \ No newline at end of file diff --git a/iac/README.md b/iac/README.md new file mode 100644 index 0000000..d781462 --- /dev/null +++ b/iac/README.md @@ -0,0 +1,123 @@ +# ZFGBB IaC (Infrastructure as Code) + +Pizza. + +## Table of Contents + +- [ZFGBB IaC (Infrastructure as Code)](#zfgbb-iac-infrastructure-as-code) + - [Table of Contents](#table-of-contents) + - [Projects](#projects) + - [Environment Setup](#environment-setup) + - [Development Process](#development-process) + - [Scripts](#scripts) + - [setup.sh](#setupsh) + - [apply.sh](#applysh) + - [status.sh](#statussh) + - [destroy.sh](#destroysh) + - [Workflow](#workflow) + - [Cleaning Up](#cleaning-up) + - [Workspace](#workspace) + - [Domain Structure](#domain-structure) + - [Notes](#notes) + +## Projects + +- [zfgc.com](./zfgc.com/README.md) + +## Environment Setup + +To setup your environment, follow the [setup instructions](../README.md#setup) in the main README. + +## Development Process + +### Scripts + +This project uses bash scripts to automate various tasks. Running the scripts requires the `bash` shell. Without passing any parameters, the scripts will display usage instructions. + +#### [setup.sh](./scripts/development/setup.sh) + +This script sets up the development environment for the project. + +```bash +./scripts/development/setup.sh +``` + +#### [apply.sh](./scripts/development/apply.sh) + +This script applies the manifests for the specified environment. + +```bash +./scripts/development/apply.sh +``` + +#### [status.sh](./scripts/development/status.sh) + +This script displays the status of the specified namespace. Namespaces are created by the [setup.sh](./scripts/development/setup.sh) script. + +```bash +./scripts/development/status.sh +``` + +#### [destroy.sh](./scripts/development/destroy.sh) + +To destroy the development environment, run the following command: + +```bash +./scripts/development/destroy.sh +``` + +## Workflow + +The workflow for developing the application is as follows: + +1. Run the [setup script](#setupsh) to configure the environment for `develop` environment. + - `./scripts/development/setup.sh zfgc.com develop` +2. Run the [apply script](#applysh) to apply the manifests for the `develop` environment. + - `./scripts/development/apply.sh zfgc.com develop` + +You can check the status of the deployment using the [status script](#statussh): + +```bash +./scripts/development/status.sh zfgc.com develop +``` + +### Cleaning Up + +To clean up the development environment, run the following command: + +```bash +./scripts/development/destroy.sh zfgc.com develop +``` + +## Workspace + +The workspace is setup to group domains and services together. + +### Domain Structure + +See [Kustomize Docs](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/) if you're unfamiliar with Kustomize. For quick reference, `kustomization.yml` is a manifest file that combines multiple other manifest files into a single file. We use [apply.sh](#applysh) to target a speific `kustomization.yml` file located in the [environments](./environments/) directory. + +```text +domain-name.tld +├── base - Defines the base resources for the domain, such as ingress and namespace. +│ ├── ingress.yml +│ ├── kustomization.yml +│ ├── namespace.yml +├── environments - Defines the environment configurations per git branch for the domain. +│ ├── [git-branch-name] +│ │ ├── kustomization.yml +│ │ ├── namespace.yml +├── services - Defines the service manifests for the domain. +│ ├── [name] +│ │ ├── deployment.yml +│ │ ├── kustomization.yml +│ │ ├── service.yml +├── scripts +│ ├── setup-environment-files.sh +``` + +## Notes + +Regarding the [Domain Structure](#domain-structure), for now, we're slightly breaking the convention and including `crystalrookarts` and legacy zfgc.com services under the `old-skool` service. This is because we're still using the old zfgc.com domain for legacy services, and we want to keep the domain name consistent. This will be addressed in the future. + +For more details, see the [ZFGBB IaC README](./zfgc.com/README.md). diff --git a/iac/scripts/common/check-minikube.sh b/iac/scripts/common/check-minikube.sh new file mode 100755 index 0000000..c29c17b --- /dev/null +++ b/iac/scripts/common/check-minikube.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Ensure this script is sourced +if [ "${BASH_SOURCE[0]}" == "${0}" ]; then + echo "This script is not meant to be executed directly. Please source it." + exit 1 +fi + +check_minikube() { + # Check if minikube is running + MINIKUBE_STATUS=$(minikube status --format '{{.Host}}' || echo "") + if [ "$MINIKUBE_STATUS" != "Running" ]; then + echo "Minikube is not running. Starting minikube..." + minikube start --driver=docker + eval "$(minikube docker-env)" + kubectl config use-context minikube + docker compose build + fi +} \ No newline at end of file diff --git a/iac/scripts/common/check-project-dir.sh b/iac/scripts/common/check-project-dir.sh new file mode 100755 index 0000000..08b54c0 --- /dev/null +++ b/iac/scripts/common/check-project-dir.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Ensure this script is sourced +if [ "${BASH_SOURCE[0]}" == "${0}" ]; then + echo "This script is not meant to be executed directly. Please source it." + exit 1 +fi + +check_project_dir() { + PROJECT_DIR=$1 + PROJECT_ENVIRONMENT=$2 + if [ ! -d "$PROJECT_DIR" ]; then + echo "Error: Project directory not found." + exit 1 + fi + + # Check if environment directory exists + ENVIRONMENT_DIR="$PROJECT_DIR/environments/$PROJECT_ENVIRONMENT" + if [ ! -d "$ENVIRONMENT_DIR" ]; then + echo "Error: Environment directory not found." + exit 1 + fi +} diff --git a/iac/scripts/development/apply.sh b/iac/scripts/development/apply.sh new file mode 100755 index 0000000..ada7230 --- /dev/null +++ b/iac/scripts/development/apply.sh @@ -0,0 +1,107 @@ +#!/bin/bash +set -e + +# Check if there are no arguments +if [ $# -eq 0 ]; then + cat < + +Example: $0 "./zfgc.com" "development" +EOF + exit 1 +fi + +PROJECT_DIR=$1 +PROJECT_ENVIRONMENT=$2 + +SCRIPT_DIR=$(dirname "$0") +source "$SCRIPT_DIR/../common/check-minikube.sh" +source "$SCRIPT_DIR/../common/check-project-dir.sh" + +check_project_dir "$PROJECT_DIR" "$PROJECT_ENVIRONMENT" +check_minikube + +cd "$PROJECT_DIR/environments/$PROJECT_ENVIRONMENT" + +source ./.env +source ./.env.secret + +export $(cut -d= -f1 ./.env) +export $(cut -d= -f1 ./.env.secret) + +kubectl kustomize . -v 9 | envsubst + +echo "" +echo "Press any key to continue..." +read -n 1 -s +clear + +echo " + █████████████████████████████████████████████████████ █████████ + █████████████████████████████████████████████████████ █████████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓████░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓████░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓████░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓████░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓████░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓████░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓████░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▓▓▓▓████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████▓▓▓▓▒ ████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████▓▓▓▓▒ ████ + █████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████▓▓▓▓▒ ████ + █████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████▓▓▓▓▒ ████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████░ ▒████████████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████░ ▒████████████ + ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ████░ ▒████████████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░ ░░░░░░░░░░░░░████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░ ░░░░░░░░░░░░░████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████ + █████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████ + █████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒████ + █████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒████ + ████░░░░█████████████████████████████████ + ████░░░░█████████████████████████████████ + ████░░░░█████████████████████████████████ + ████░░░░████████▓▓▓▓░░░░░░░░░░░░█████████████████ + ████░░░░████████▓▓▓▓░░░░░░░░░░░░█████████████████ + ████░░░░████ ████░░░░░░░░░░░░████░ ████ + ████░░░░████ ████░░░░░░░░░░░░████░ ████ + ████████ ████░░░░░░░░████░ ████ + ████████ ████░░░░░░░░████░ ████ + ████ ████████░░░░████░ ▒████ + ████ ████████░░░░████░ ▒████ + ████ ████████▓▓▓▓█████████████████ + ████ ████████▓▓▓▓█████████████████ + ████ ████████▓▓▓▓█████████████████ + ████████▓▓▓▓████████████ + ████████▓▓▓▓████████████ + ████████▓▓▓▓████▓▓▓▓▓▓▓▓█████████ + ████████▓▓▓▓████▓▓▓▓▓▓▓▓█████████ + ████████▓▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓░ ▒████████ + ████████▓▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓░ ▒████████ + ████▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓████ + ████▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓████ + █████████████████████████████████████████████████████ + █████████████████████████████████████████████████████ + +" + +echo "Applying kustomize build..." + +# Use envsubst to replace environment variables in the kustomization.yml file +kustomize build . | envsubst | kubectl apply -f - +cd - + +echo "Deployments have been applied." \ No newline at end of file diff --git a/iac/scripts/development/destroy.sh b/iac/scripts/development/destroy.sh new file mode 100755 index 0000000..d59215a --- /dev/null +++ b/iac/scripts/development/destroy.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Check if there are no arguments +if [ $# -eq 0 ]; then + cat < + +Example: $0 "./zfgc.com" "development" +EOF + exit 1 +fi + +PROJECT_DIR=$(realpath "$1") +PROJECT_ENVIRONMENT=$2 + +SOURCE_DIR=$(dirname "$0") +source "$SOURCE_DIR/../common/check-minikube.sh" + +check_minikube + +kustomize build "$PROJECT_DIR/environments/$PROJECT_ENVIRONMENT" | kubectl delete -f - diff --git a/iac/scripts/development/setup.sh b/iac/scripts/development/setup.sh new file mode 100755 index 0000000..1a26450 --- /dev/null +++ b/iac/scripts/development/setup.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +# Check if there are no arguments +if [ $# -eq 0 ]; then + cat < + +Example: $0 "./zfgc.com" "development" +EOF + exit 1 +fi + +PROJECT_DIR=$(realpath "$1") +PROJECT_ENVIRONMENT=$2 + +SOURCE_DIR=$(dirname "$0") +source "$SOURCE_DIR/../common/check-minikube.sh" +source "$SOURCE_DIR/../common/check-project-dir.sh" + + +source "$PROJECT_DIR/scripts/setup-environment-files.sh" +setup "$PROJECT_DIR" "$PROJECT_ENVIRONMENT" \ No newline at end of file diff --git a/iac/scripts/development/status.sh b/iac/scripts/development/status.sh new file mode 100755 index 0000000..7f23776 --- /dev/null +++ b/iac/scripts/development/status.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +# Check if there are no arguments +if [ $# -eq 0 ]; then + cat < + +Example: $0 zfgbb-develop +EOF + exit 1 +fi + +ENVIRONMENT_TARGET=$1 || "zfgbb-develop" + +SCRIPT_DIR=$(dirname "$0") +source "$SCRIPT_DIR/../common/check-minikube.sh" + +check_minikube + +kubectl describe deployments -n "$ENVIRONMENT_TARGET" + +echo "Press any key to continue..." +read -n 1 -s +clear + +kubectl describe services -n "$ENVIRONMENT_TARGET" + +echo "Press any key to continue..." +read -n 1 -s +clear + +kubectl describe pods -n "$ENVIRONMENT_TARGET" + +echo "Press any key to continue..." +read -n 1 -s +clear \ No newline at end of file diff --git a/iac/scripts/linode/provision-linode.sh b/iac/scripts/linode/provision-linode.sh new file mode 100755 index 0000000..54df9c7 --- /dev/null +++ b/iac/scripts/linode/provision-linode.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +sudo apt update && sudo apt upgrade -y +sudo apt install apt-transport-https curl -y + +sudo apt install containerd -y + + +sudo mkdir -p /etc/containerd +sudo containerd config default | sudo tee /etc/containerd/config.toml > /dev/null +sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml +sudo systemctl restart containerd + + +curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg +# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list +echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list +sudo apt-get update +sudo apt-get install -y kubelet kubeadm kubectl +sudo apt-mark hold kubelet kubeadm kubectl +sudo systemctl enable --now kubelet +sudo cat < "$TARGET_ENV_FILE" < "$TARGET_ENV_FILE.secret" <org.springframework.boot spring-boot-maven-plugin + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.4.2 + diff --git a/scripts/development/setup.sh b/scripts/development/setup.sh new file mode 100644 index 0000000..49449c3 --- /dev/null +++ b/scripts/development/setup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +# Check what OS we're running on +OS=$(uname -s) + +SCRIPT_DIR=$(dirname "$0") + +# Source the setup function for the current OS +if [ "$OS" == "Linux" ]; then + source "$SCRIPT_DIR/setup/setup-linux.sh" +elif [ "$OS" == "Darwin" ]; then + source "$SCRIPT_DIR/setup/setup-macos.sh" +else + source "$SCRIPT_DIR/setup/setup-windows.sh" +fi diff --git a/scripts/development/setup/setup-darwin.sh b/scripts/development/setup/setup-darwin.sh new file mode 100644 index 0000000..4bc5535 --- /dev/null +++ b/scripts/development/setup/setup-darwin.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +if [ "$EUID" -ne 0 ]; then + echo "Please run this script as root." + exit 1 +fi + +brew update +echo "Do you want to install Docker Desktop, Kubernetes CLI, and Minikube? (y/n)" +read -r answer +if [ "$answer" == "y" ]; then + echo "Installing Docker Desktop, Kubernetes CLI, and Minikube..." + brew install docker docker-compose minikube +else + echo "Skipping installation of Docker Desktop, Kubernetes CLI, and Minikube." +fi + +java_version=$(java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}') +if [ "$java_version" != "17" ]; then + echo "Java JDK 17 is not installed. Do you want to install it now? (y/n)" + read -r answer + if [ "$answer" == "y" ]; then + echo "Installing Java JDK 17..." + brew install openjdk@17 + else + echo "Skipping installation of Java JDK 17." + fi +fi + +mvn --version > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "mvn is not installed. Do you want to install it now? (y/n)" + read -r answer + if [ "$answer" == "y" ]; then + echo "Installing mvn..." + brew install maven + else + echo "Skipping installation of mvn." + fi +fi diff --git a/scripts/development/setup/setup-linux.sh b/scripts/development/setup/setup-linux.sh new file mode 100644 index 0000000..76f8fba --- /dev/null +++ b/scripts/development/setup/setup-linux.sh @@ -0,0 +1,107 @@ +#!/bin/bash +set -e + +INSTALL_IAC_STUFF=false +INSTALL_JAVA_STUFF=false + +echo "Do you want to install Docker, Docker Compose, and Minikube? (y/n)" +read -r answer +if [ "$answer" == "y" ]; then + INSTALL_IAC_STUFF=true +fi + +echo "Do you want to install Java JDK 17? (y/n)" +read -r answer +if [ "$answer" == "y" ]; then + INSTALL_JAVA_STUFF=true +fi + +install_ubuntu() { + sudo apt-get update + if [ "$INSTALL_IAC_STUFF" = true ]; then + sudo apt-get install -y docker.io docker-compose minikube + fi + + if [ "$INSTALL_JAVA_STUFF" = true ]; then + sudo apt-get install -y openjdk-17-jdk maven + fi +} + +install_arch() { + sudo pacman -Syu + if [ "$INSTALL_IAC_STUFF" = true ]; then + sudo pacman -S docker docker-compose minikube + fi + + if [ "$INSTALL_JAVA_STUFF" = true ]; then + sudo pacman -S openjdk17-jdk maven + fi +} + +install_unknown() { + echo "We don't know your distro. So, we'll just check the presence of the dependencies." + + if [ "$INSTALL_IAC_STUFF" = true ]; then + if ! command -v docker &> /dev/null; then + echo "Docker is not installed. Please install it first." + fi + if ! command -v kubectl &> /dev/null; then + echo "Kubernetes CLI is not installed. Please install it first." + fi + if ! command -v minikube &> /dev/null; then + echo "Minikube is not installed. Please install it first." + fi + fi + + if [ "$INSTALL_JAVA_STUFF" = true ]; then + if ! command -v java &> /dev/null; then + echo "Java JDK 17 is not installed. Please install it first." + else + java_version=$(java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}') + if [ "$java_version" != "17" ]; then + echo "Java JDK 17 is not installed. Please install it first." + fi + fi + + if ! command -v mvn &> /dev/null; then + echo "mvn is not installed. Please install it first." + fi + fi + + exit 0 +} + +# Check distro +if [ "$(lsb_release -si)" == "Ubuntu" ]; then + install_ubuntu +# Else if we're running on Arch Linux +elif [ "$(lsb_release -si)" == "Arch" ]; then + install_arch +else + install_unknown +fi + +echo "Starting Docker..." +sudo systemctl start docker +echo "Docker started successfully." +echo "Installing Minikube..." + +#grab cpu arch for minikube +cpu_arch=$(uname -m) + +if [ "$cpu_arch" == "x86_64" ]; then + cpu_arch="amd64" +elif [ "$cpu_arch" == "aarch64" ]; then + cpu_arch="arm64" +else + echo "Unknown CPU architecture. Please install Minikube manually." + exit 1 +fi + +curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64 +sudo install minikube-linux-$cpu_arch /usr/local/bin/minikube && rm minikube-linux-$cpu_arch +echo "Minikube installed successfully." + +minikube start --driver=docker +eval "$(minikube docker-env)" +kubectl config use-context minikube diff --git a/scripts/development/setup/setup-windows.sh b/scripts/development/setup/setup-windows.sh new file mode 100644 index 0000000..3a221cb --- /dev/null +++ b/scripts/development/setup/setup-windows.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +if ! command -v winget &> /dev/null; then + echo "winget is not installed. Please install it first." + exit 1 +fi + +if [ "$(whoami)" != "Administrator" ]; then + echo "Please run this script as an administrator." + exit 1 +fi + +wsl --list --quiet > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "WSL is not installed. Do you want to install it now? (y/n)" + read -r answer + if [ "$answer" == "y" ]; then + wsl --install + fi +fi + +echo "Do you want to install Docker Desktop, Kubernetes CLI, and Minikube? (y/n)" +read -r answer +if [ "$answer" == "y" ]; then + echo "Installing Docker Desktop, Kubernetes CLI, and Minikube..." + winget install -e --id Docker.DockerDesktop + winget install -e --id Kubernetes.kubectl + winget install -e --id Kubernetes.minikube + minikube start --driver=docker + eval "$(minikube docker-env)" + kubectl config use-context minikube +else + echo "Skipping installation of Docker Desktop, Kubernetes CLI, and Minikube." +fi + +java_version=$(java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}') +if [ "$java_version" != "17" ]; then + echo "Java JDK 17 is not installed. Do you want to install it now? (y/n)" + read -r answer + if [ "$answer" == "y" ]; then + echo "Installing Java JDK 17..." + winget install -e --id Eclipse.OpenJDK17 + else + echo "Skipping installation of Java JDK 17." + fi +fi + +# Ask if we want to install mvn, first check if mvn is installed +mvn --version > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "mvn is not installed. Do you want to install it now? (y/n)" + read -r answer + if [ "$answer" == "y" ]; then + echo "Installing mvn..." + winget install -e --id Apache.Maven + else + echo "Skipping installation of mvn." + fi +fi \ No newline at end of file diff --git a/scripts/sql/provisioning/1-zfgbb.initialize-database.sh b/scripts/sql/provisioning/1-zfgbb.initialize-database.sh new file mode 100644 index 0000000..ee4864f --- /dev/null +++ b/scripts/sql/provisioning/1-zfgbb.initialize-database.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then +cat < /dev/null && pwd )" +psql --username "$POSTGRES_USER" --dbname "$ZFGBB_DATABASE" -a -f "$SCRIPT_DIR/2-provision-database" \ No newline at end of file diff --git a/scripts/sql/provisioning/2-provision-database.sql b/scripts/sql/provisioning/2-provision-database.sql new file mode 100644 index 0000000..426cd13 --- /dev/null +++ b/scripts/sql/provisioning/2-provision-database.sql @@ -0,0 +1,283 @@ +CREATE SEQUENCE IF NOT EXISTS PUBLIC.BOARD_SEQUENCE START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.ATTRIBUTE_DATA_TYPE_ATTRIBUTE_DATA_TYPE_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BB_CODE_ATTRIBUTE_BB_CODE_ATTRIBUTE_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BB_CODE_ATTRIBUTE_MODE_BB_CODE_ATTRIBUTE_MODE_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BB_CODE_CONFIG_BB_CODE_CONFIG_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BOARD_BOARD_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BR_BOARD_PERMISSION_BR_BOARD_PERMISSION_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.BR_USER_PERMISSION_BR_USER_PERMISSION_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.EMAIL_ADDRESS_EMAIL_ADDRESS_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.FORUM_FORUM_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.MESSAGE_HISTORY_MESSAGE_HISTORY_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.MESSAGE_MESSAGE_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.PERMISSION_PERMISSION_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.THREAD_THREAD_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS ZFGBB.USER_USER_ID_SEQ AS INTEGER START +WITH + 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE TABLE IF NOT EXISTS ZFGBB.IP_ADDRESS ( + IP_ADDRESS_ID INTEGER NOT NULL, + IP TEXT NOT NULL, + IP_V6_FLAG BOOLEAN NOT NULL, + IS_SPAMMER_FLAG BOOLEAN NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT IP_ADDRESS_PKEY PRIMARY KEY (IP_ADDRESS_ID) +); + +ALTER TABLE IF EXISTS ZFGBB.IP_ADDRESS OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.ATTRIBUTE_DATA_TYPE ( + ATTRIBUTE_DATA_TYPE_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + TYPE_NAME TEXT NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE IF EXISTS ZFGBB.ATTRIBUTE_DATA_TYPE OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.BB_CODE_ATTRIBUTE ( + BB_CODE_ATTRIBUTE_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + ATTRIBUTE_DATA_TYPE INTEGER NOT NULL, + ATTRIBUTE_INDEX INTEGER NOT NULL, + BB_CODE_ATTRIBUTE_MODE_ID INTEGER NOT NULL, + NAME TEXT NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE IF EXISTS ZFGBB.BB_CODE_ATTRIBUTE OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.BB_CODE_ATTRIBUTE_MODE ( + BB_CODE_ATTRIBUTE_MODE_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + BB_CODE_CONFIG_ID INTEGER NOT NULL, + CONTENT_IS_ATTRIBUTE_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + OPEN_TAG TEXT NOT NULL, + CLOSE_TAG TEXT NOT NULL, + OUTPUT_CONTENT_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE IF EXISTS ZFGBB.BB_CODE_ATTRIBUTE_MODE OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.BB_CODE_CONFIG ( + BB_CODE_CONFIG_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + CODE TEXT NOT NULL, + END_TAG TEXT NOT NULL, + PROCESS_CONTENT_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT BB_CODE_CONFIG_CODE_KEY UNIQUE (CODE) +); + +ALTER TABLE IF EXISTS ZFGBB.BB_CODE_CONFIG OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.PERMISSION ( + PERMISSION_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + PERMISSION_NAME CHARACTER VARYING(32) NOT NULL, + PERMISSION_CODE CHARACTER VARYING(64) NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +ALTER TABLE IF EXISTS ZFGBB.PERMISSION OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.USER ( + USER_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + SSO_KEY CHARACTER VARYING(64) NOT NULL, + ACTIVE_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + DISPLAY_NAME CHARACTER VARYING NOT NULL +); + +ALTER TABLE IF EXISTS ZFGBB.USER OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.CATEGORY ( + CATEGORY_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + CATEGORY_NAME CHARACTER VARYING(32) NOT NULL, + DESCRIPTION CHARACTER VARYING(64), + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP, + PARENT_BOARD_ID INTEGER +); + +ALTER TABLE IF EXISTS ZFGBB.CATEGORY OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.BOARD ( + BOARD_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + BOARD_NAME TEXT NOT NULL, + DESCRIPTION TEXT, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP, + CATEGORY_ID INTEGER, + CONSTRAINT FK_BOARD_CATEGORY_ID FOREIGN KEY (CATEGORY_ID) REFERENCES ZFGBB.CATEGORY (CATEGORY_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.BOARD OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.THREAD ( + THREAD_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + THREAD_NAME CHARACTER VARYING(64) NOT NULL, + LOCKED_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + PINNED_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + BOARD_ID INTEGER NOT NULL, + CREATED_USER_ID INTEGER NOT NULL, + CONSTRAINT FK_THREAD_BOARD_ID FOREIGN KEY (BOARD_ID) REFERENCES ZFGBB.BOARD (BOARD_ID) NOT VALID, + CONSTRAINT FK_THREAD_CREATED_USER_ID FOREIGN KEY (CREATED_USER_ID) REFERENCES ZFGBB.USER (USER_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.THREAD OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.MESSAGE ( + MESSAGE_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + OWNER_ID INTEGER NOT NULL, + THREAD_ID INTEGER, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + POST_IN_THREAD INTEGER DEFAULT 0 NOT NULL, + CONSTRAINT FK_MESSAGE_THREAD_ID FOREIGN KEY (THREAD_ID) REFERENCES ZFGBB.THREAD (THREAD_ID) NOT VALID, + CONSTRAINT FK_MESSAGE_USER_ID FOREIGN KEY (OWNER_ID) REFERENCES ZFGBB.USER (USER_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.MESSAGE OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.MESSAGE_HISTORY ( + MESSAGE_HISTORY_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + MESSAGE_ID INTEGER NOT NULL, + MESSAGE_TEXT TEXT NOT NULL, + CURRENT_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + IP_ADDRESS_ID INTEGER NOT NULL, + CONSTRAINT FK_MESSAGE_HISTORY_IP_ADDRESS_ID FOREIGN KEY (IP_ADDRESS_ID) REFERENCES ZFGBB.IP_ADDRESS (IP_ADDRESS_ID) NOT VALID, + CONSTRAINT FK_MESSAGE_HISTORY_MESSAGE_ID FOREIGN KEY (MESSAGE_ID) REFERENCES ZFGBB.MESSAGE (MESSAGE_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.MESSAGE_HISTORY OWNER TO ZFGCADMIN; + + +CREATE TABLE IF NOT EXISTS ZFGBB.EMAIL_ADDRESS ( + EMAIL_ADDRESS_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + EMAIL_ADDRESS CHARACTER VARYING(32) NOT NULL, + CREATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + UPDATED_TS TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + SPAMMER_FLAG BOOLEAN DEFAULT FALSE NOT NULL, + USER_ID INTEGER, + CONSTRAINT UN_EMAIL_ADDRESS_USER_ID UNIQUE (USER_ID), + CONSTRAINT FK_EMAIL_ADDRESS_USER_ID FOREIGN KEY (USER_ID) REFERENCES ZFGBB.USER (USER_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.EMAIL_ADDRESS OWNER TO ZFGCADMIN; + +CREATE TABLE IF NOT EXISTS ZFGBB.BR_BOARD_PERMISSION ( + BR_BOARD_PERMISSION_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + BOARD_ID INTEGER NOT NULL, + PERMISSION_ID INTEGER NOT NULL, + CONSTRAINT UN_BOARD_PERMISSION UNIQUE (BOARD_ID, PERMISSION_ID), + CONSTRAINT FK_BOARD_PERMISSION_BOARD_ID FOREIGN KEY (BOARD_ID) REFERENCES ZFGBB.BOARD (BOARD_ID) NOT VALID, + CONSTRAINT FK_BOARD_PERMISSION_PERMISSION_ID FOREIGN KEY (PERMISSION_ID) REFERENCES ZFGBB.PERMISSION (PERMISSION_ID) NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.BR_BOARD_PERMISSION OWNER TO ZFGCADMIN; + +CREATE OR REPLACE VIEW ZFGBB.BOARD_PERMISSION_VIEW AS +SELECT + B.BOARD_ID, + P.PERMISSION_ID, + P.PERMISSION_CODE, + P.PERMISSION_NAME +FROM + ( + ( + ZFGBB.BR_BOARD_PERMISSION BR + JOIN ZFGBB.PERMISSION P ON ((P.PERMISSION_ID = BR.PERMISSION_ID)) + ) + JOIN ZFGBB.BOARD B ON ((B.BOARD_ID = BR.BOARD_ID)) + ); + +CREATE TABLE IF NOT EXISTS ZFGBB.BR_USER_PERMISSION ( + BR_USER_PERMISSION_ID INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + USER_PERMISSION_ID INTEGER NOT NULL, + USER_ID INTEGER NOT NULL, + CONSTRAINT FK_BR_USER_PERMISSION_ID_USER_ID FOREIGN KEY (USER_ID) REFERENCES ZFGBB.USER (USER_ID) MATCH FULL NOT VALID, + CONSTRAINT FK_BR_USER_PERMISSION_PERMISSION_ID FOREIGN KEY (USER_PERMISSION_ID) REFERENCES ZFGBB.PERMISSION (PERMISSION_ID) MATCH FULL NOT VALID +); + +ALTER TABLE IF EXISTS ZFGBB.BR_USER_PERMISSION OWNER TO ZFGCADMIN; + +CREATE OR REPLACE VIEW ZFGBB.USER_PERMISSION_VIEW AS +SELECT + U.USER_ID, + P.PERMISSION_ID, + P.PERMISSION_CODE +FROM + ( + ZFGBB.BR_USER_PERMISSION U + JOIN ZFGBB.PERMISSION P ON ((P.PERMISSION_ID = U.USER_PERMISSION_ID)) + ); + +CREATE OR REPLACE VIEW ZFGBB.CURRENT_MESSAGE_VIEW AS +SELECT + M.MESSAGE_ID, + M.OWNER_ID, + M.THREAD_ID, + H.MESSAGE_TEXT, + H.MESSAGE_HISTORY_ID, + M.POST_IN_THREAD +FROM + ( + ZFGBB.MESSAGE M + JOIN ZFGBB.MESSAGE_HISTORY H ON ( + ( + (H.MESSAGE_ID = M.MESSAGE_ID) + AND (H.CURRENT_FLAG = TRUE) + ) + ) + ); diff --git a/src/main/java/com/zfgc/zfgbb/ZfgbbApplication.java b/src/main/java/com/zfgc/zfgbb/ZfgbbApplication.java index 61381e4..60300af 100644 --- a/src/main/java/com/zfgc/zfgbb/ZfgbbApplication.java +++ b/src/main/java/com/zfgc/zfgbb/ZfgbbApplication.java @@ -42,7 +42,7 @@ public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**").allowedOrigins("http://localhost:5173","http://dev3.zfgc.com"); + registry.addMapping("/**").allowedOrigins("http://localhost:5173","http://dev3.zfgc.com", "http://www.zfgc.com", "https://www.zfgc.com", "http://zfgc.com", "https://zfgc.com"); } }; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 20566f5..90e43bd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/zfgc_dev -spring.datasource.username= -spring.datasource.password= +spring.datasource.username=zfgbbadmin +spring.datasource.password=123456 spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.validation-query=SELECT 1 spring.datasource.max-wait=10000 @@ -20,10 +20,10 @@ spring.flyway.executeInTransaction=true spring.flyway.repairAtStart=true mbg.jdbc.url=jdbc:postgresql://localhost:5432/zfgc_dev -mbg.jdbc.username= -mbg.jdbc.password= +mbg.jdbc.username=zfgbbadmin +mbg.jdbc.password=123456 mbg.jdbc.driver-class-name=org.postgresql.Driver -mbg.jdbc.driver-location +#mbg.jdbc.driver-location mbg.target-package.mapper=com.zfgc.zfgcbb.mappers mbg.target-package.domain=com.zfgc.zfgcbb.dbo mbg.target-project.java=src/main/java @@ -35,3 +35,7 @@ clausius.password= clausius.authEndpoint= server.servlet.context-path=/zfgbb + +zfgbb.content.path=./ +zfgbb.content.images=./images +mybatis.config-location=classpath:/config/mybatis-config.xml \ No newline at end of file diff --git a/src/main/java/com/zfgc/zfgbb/mappers/AttributeDataTypeDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/AttributeDataTypeDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/AttributeDataTypeDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/AttributeDataTypeDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/AvatarDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/AvatarDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/AvatarDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/AvatarDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BBCodeAttributeDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BBCodeAttributeDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BBCodeAttributeDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BBCodeAttributeDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BBCodeAttributeModeDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BBCodeAttributeModeDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BBCodeAttributeModeDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BBCodeAttributeModeDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BBCodeConfigDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BBCodeConfigDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BBCodeConfigDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BBCodeConfigDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BoardDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BoardDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BoardDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BoardDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BoardPermissionViewDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BoardPermissionViewDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BoardPermissionViewDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BoardPermissionViewDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/BoardSummaryViewDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/BoardSummaryViewDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/BoardSummaryViewDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/BoardSummaryViewDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/CategoryDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/CategoryDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/CategoryDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/CategoryDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/ChildBoardViewDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/ChildBoardViewDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/ChildBoardViewDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/ChildBoardViewDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/ContentResourceDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/ContentResourceDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/ContentResourceDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/ContentResourceDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/CurrentMessageDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/CurrentMessageDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/CurrentMessageDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/CurrentMessageDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/EmailAddressDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/EmailAddressDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/EmailAddressDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/EmailAddressDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/FileAttachmentDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/FileAttachmentDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/FileAttachmentDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/FileAttachmentDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/IpAddressDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/IpAddressDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/IpAddressDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/IpAddressDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/LatestMessageInThreadViewDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/LatestMessageInThreadViewDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/LatestMessageInThreadViewDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/LatestMessageInThreadViewDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/MessageDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/MessageDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/MessageDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/MessageDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/MessageHistoryDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/MessageHistoryDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/MessageHistoryDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/MessageHistoryDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/PollDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/PollDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/PollDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/PollDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/PollQuestionDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/PollQuestionDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/PollQuestionDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/PollQuestionDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/ThreadDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/ThreadDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/ThreadDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/ThreadDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/ThreadboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/ThreadboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/ThreadboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/ThreadboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/UserBioInfoDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/UserBioInfoDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/UserBioInfoDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/UserBioInfoDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/UserDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/UserDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/UserDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/UserDboMapper.xml diff --git a/src/main/java/com/zfgc/zfgbb/mappers/UserPermissionViewDboMapper.xml b/src/main/resources/com/zfgc/zfgbb/mappers/UserPermissionViewDboMapper.xml similarity index 100% rename from src/main/java/com/zfgc/zfgbb/mappers/UserPermissionViewDboMapper.xml rename to src/main/resources/com/zfgc/zfgbb/mappers/UserPermissionViewDboMapper.xml diff --git a/src/main/resources/config/mybatis-config.xml b/src/main/resources/config/mybatis-config.xml new file mode 100644 index 0000000..d362c63 --- /dev/null +++ b/src/main/resources/config/mybatis-config.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/config/spring-mybatis.xml b/src/main/resources/config/spring-mybatis.xml new file mode 100644 index 0000000..a03ea83 --- /dev/null +++ b/src/main/resources/config/spring-mybatis.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/db/migration/functions/R__03_bbcodes.sql b/src/main/resources/db/migration/functions/R__02_bbcodes.sql similarity index 100% rename from src/main/resources/db/migration/functions/R__03_bbcodes.sql rename to src/main/resources/db/migration/functions/R__02_bbcodes.sql diff --git a/src/main/resources/db/migration/functions/R__02_permissions.sql b/src/main/resources/db/migration/functions/V20240930.1_permissions.sql similarity index 100% rename from src/main/resources/db/migration/functions/R__02_permissions.sql rename to src/main/resources/db/migration/functions/V20240930.1_permissions.sql diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index d668cc7..1c70d1c 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -5,16 +5,16 @@ - + - + - + - +