diff --git a/frontend/.editorconfig b/.editorconfig similarity index 94% rename from frontend/.editorconfig rename to .editorconfig index fbace8d..0880aa5 100644 --- a/frontend/.editorconfig +++ b/.editorconfig @@ -5,6 +5,7 @@ root = true charset = utf-8 indent_style = space indent_size = 2 +tab_width = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true @@ -12,4 +13,3 @@ trim_trailing_whitespace = true [*.md] insert_final_newline = false trim_trailing_whitespace = false - diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1d7852 --- /dev/null +++ b/.gitignore @@ -0,0 +1,71 @@ +# Common +.DS_Store +.idea/ +*.iws +*.iml +*.ipr +*.suo +*.ntvs* +*.njsproj +*.sln +*.log +*.swp + +# Frontend workspace +/frontend/**/node_modules/ +/frontend/**/.eslintcache +/frontend/**/tsconfig.tsbuildinfo +/frontend/**/*.local + +# Frontend app +/frontend/app/dist/ +/frontend/app/deploy_versions/ +/frontend/app/.temp/ +/frontend/app/.rn_temp/ +/frontend/app/.swc + +# Frontend web +/frontend/web/dist/ +/frontend/web/dist-ssr/ +/frontend/web/report.html +/frontend/web/yarn.lock +/frontend/web/npm-debug.log* +/frontend/web/.pnpm-error.log* +/frontend/web/.pnpm-debug.log +/frontend/web/tests/**/coverage/ +/frontend/web/.vscode/launch.json + +# Backend build tools +/backend/.gradle/ +/backend/build/ +!/backend/gradle/wrapper/gradle-wrapper.jar +/backend/**/target/ +!/backend/.mvn/wrapper/maven-wrapper.jar + +# Backend IDE +/backend/**/.apt_generated +/backend/**/.classpath +/backend/**/.factorypath +/backend/**/.project +/backend/**/.settings/ +/backend/**/.springBeans + +# Backend JRebel +/backend/**/rebel.xml + +# Backend NetBeans +/backend/nbproject/private/ +/backend/build/* +/backend/nbbuild/ +/backend/dist/ +/backend/nbdist/ +/backend/.nb-gradle/ + +# Backend generated files +/backend/**/*.xml.versionsBackup +!/backend/*/build/*.java +!/backend/*/build/*.html +!/backend/*/build/*.xml + +# Backend local configuration +/backend/agileboot-admin/src/main/resources/application-prod.yml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..e70e633 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,12 @@ +{ + "recommendations": [ + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "stylelint.vscode-stylelint", + "Vue.volar", + "bradlc.vscode-tailwindcss", + "mikestead.dotenv", + "antfu.iconify" + ] +} diff --git a/frontend/web/.vscode/settings.json b/.vscode/settings.json similarity index 53% rename from frontend/web/.vscode/settings.json rename to .vscode/settings.json index 9b434de..2e05277 100644 --- a/frontend/web/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,32 +1,43 @@ { - "editor.formatOnType": true, - "editor.formatOnSave": true, - "[vue]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, + "editor.detectIndentation": false, "editor.tabSize": 2, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, "editor.formatOnPaste": true, + "editor.formatOnType": true, "editor.guides.bracketPairs": "active", - "files.autoSave": "afterDelay", - "git.confirmSync": false, - "workbench.startupEditor": "newUntitledFile", + "editor.snippetSuggestions": "top", "editor.suggestSelection": "first", "editor.acceptSuggestionOnCommitCharacter": false, - "css.lint.propertyIgnoredDueToDisplay": "ignore", "editor.quickSuggestions": { "other": true, "comments": true, "strings": true }, - "files.associations": { - "editor.snippetSuggestions": "top" + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.fixAll.stylelint": "explicit" + }, + "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"], + "stylelint.validate": ["css", "scss", "vue"], + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[css]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "[scss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "iconify.excludes": ["el"], - "cSpell.words": ["iconify", "Qrcode"] + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "css.lint.propertyIgnoredDueToDisplay": "ignore", + "files.autoSave": "afterDelay", + "git.confirmSync": false, + "workbench.startupEditor": "newUntitledFile", + "iconify.excludes": ["el"] } diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..4f85cd9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,15 @@ +# Agent Rules + +- 新增或修改代码前,必须阅读并遵循 `docs/clean-code-contract.md`。 +- 后端新增或修改业务功能前,必须阅读 `docs/backend-feature-development.md`。 +- 后端代码必须遵循 `Controller -> ApplicationService -> Model -> db Service/Mapper` 的组织方式。 +- 不要把业务规则写在 Controller。 +- 不要让 Controller 直接调用 Mapper。 +- 不要直接把 Entity 或 DO 返回给前端。 +- 复杂查询结果对象可以使用 `XxxDO`,放在 `db` 包下,并由 ApplicationService 转换为 DTO。 +- 字典类需求不要默认创建字典管理表;本项目现有字典数据使用 Enum 和缓存。 +- `frontend/web` 新增或修改业务功能前,必须阅读 `docs/web-feature-development.md`。 +- Web 前端接口必须通过 `@/utils/http` 封装调用,不要直接使用 Axios。 +- Web 列表页复杂状态和行为应放在 `utils/hook.tsx`,不要堆在 `index.vue`。 +- Web 页面私有组件放在当前模块的 `components/`,多模块复用组件提升到 `frontend/web/src/components`。 +- Web 字典展示优先使用 `useUserStoreHook().dictionaryList` 或 `dictionaryMap`,不要硬编码状态文本和值。 diff --git a/README.md b/README.md index cae1036..6c9afb8 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,31 @@ cd backend docker compose up -d ``` -On a fresh Docker volume, Compose creates the MySQL database `agileboot_pure`. -Import the SQL files under `backend/sql/` before starting the backend. +The compose configuration mounts `backend/sql/agileboot.sql` into the MySQL +container as `/docker-entrypoint-initdb.d/01-agileboot.sql`. +The official MySQL image only runs files in `/docker-entrypoint-initdb.d` when +the database directory is empty, during the first initialization of the +`mysql_data` volume. + +If MySQL has already been started before, the `mysql_data` volume already +contains data and `docker compose up -d` will not import the SQL again. To +reinitialize the local database, remove the volumes first: + +```bash +cd backend +docker compose down -v +docker compose up -d +``` + +Warning: `docker compose down -v` deletes the local MySQL and Redis volumes, +including existing database data and Redis data. + +If you do not want to delete the volumes, import the SQL manually: + +```bash +cd backend +docker exec -i mysql-server mysql -uroot -proot123 agileboot_pure < sql/agileboot.sql +``` ### Install Frontend Dependencies @@ -50,7 +73,7 @@ Start the backend: ```bash cd backend -./mvnw -pl agileboot-admin -am spring-boot:run +./mvnw -pl agileboot-admin spring-boot:run ``` Start the web frontend: diff --git a/backend/.github/ISSUE_TEMPLATE/bug_report.md b/backend/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index ab0e815..0000000 --- a/backend/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: Bug 报告 -about: 创建BUG报告以改进项目 -title: '' -labels: '' -assignees: '' - ---- - -**BUG描述** -关于BUG清晰简洁的描述。 - -**复现步骤** -详细的复现步骤。 - - -**正确的行为** -你认为这个修复这个BUG后,正确的行为应该是什么。 - - -**详细截图** -如果可以的话,请添加截图以帮助调查BUG. - -**桌面端:** - - 操作系统: [例如. iOS] - - 浏览器及版本 [例如. chrome 11] - - 项目版本 [例如. 1.6.0] - -**手机端:** - - 设备: [例如. iPhone6] - - 操作系统: [例如. iOS8.1] - - 浏览器及版本 [例如.safari 8] - - 项目版本 [例如. 1.6.0] - -**Additional context** -任何其他你认为有助于排查错误的信息,或者你的猜测。 diff --git a/backend/.github/ISSUE_TEMPLATE/feature_request.md b/backend/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 913a980..0000000 --- a/backend/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: 功能建议 -about: 关于该项目的建议 -title: '' -labels: '' -assignees: '' - ---- - -**您的功能请求是否与问题相关? 请描述。** -清楚简明地描述问题所在。 - -**描述您想要的解决方案** -对您所设想的问题的清晰简洁的描述。 - -**描述您考虑过的替代方案** -对您考虑过的任何替代解决方案或功能的清晰简洁的描述。 - -**附加上下文** -在此处添加有关功能请求的任何其他上下文或屏幕截图。 diff --git a/backend/.github/workflows/ci-cd.yml b/backend/.github/workflows/ci-cd.yml deleted file mode 100644 index 4a7a5a7..0000000 --- a/backend/.github/workflows/ci-cd.yml +++ /dev/null @@ -1,116 +0,0 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# 权限声明,确保 workflow 有权限写 checks 和 security-events -permissions: - contents: read - checks: write - security-events: write - -name: Java CI with Maven - -on: - push: - branches: [ "main" ] - paths-ignore: - - 'README.md' - - 'LICENSE' - - '.gitignore' - - '.gitattributes' - - 'picture' - pull_request: - branches: [ "main" ] - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 30 - strategy: - matrix: - java-version: ['8', '17', '21'] - fail-fast: false - - name: Build with Java ${{ matrix.java-version }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java-version }} - distribution: 'temurin' - cache: 'maven' - - # 优化Maven本地仓库缓存策略 - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}-${{ matrix.java-version }} - restore-keys: | - ${{ runner.os }}-m2- - - # 编译和测试:去掉failOnWarning,避免因为警告导致失败 - - name: Build and Test with Maven - run: | - mvn -B verify --file pom.xml -Dmaven.test.failure.ignore=false -Dgpg.skip -Dmaven.javadoc.skip=false - env: - MAVEN_OPTS: -Xmx4g -XX:MaxMetaspaceSize=1g - MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" - - - name: Publish Test Report - uses: mikepenz/action-junit-report@v4 - if: success() || failure() - with: - report_paths: '**/target/surefire-reports/TEST-*.xml' - detailed_summary: true - include_passed: true - fail_on_failure: true - - - name: Run SonarQube Analysis - if: matrix.java-version == '17' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - continue-on-error: true - run: | - if [[ ! -z "${{ secrets.SONAR_TOKEN }}" ]]; then - mvn sonar:sonar \ - -Dsonar.projectKey=agileboot \ - -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION || 'default' }} \ - -Dsonar.host.url=${{ secrets.SONAR_HOST_URL || 'https://sonarcloud.io' }} \ - -Dsonar.login=${{ secrets.SONAR_TOKEN }} \ - -Dsonar.java.source=${{ matrix.java-version }} - else - echo "Skipping SonarQube analysis - SONAR_TOKEN not configured" - fi - - # 上传构建产物,if-no-files-found 改为 warn - - name: Upload Build Artifacts - uses: actions/upload-artifact@v4 - with: - name: agileboot-artifacts-java-${{ matrix.java-version }} - path: | - **/target/*.jar - !**/target/original-*.jar - retention-days: 5 - if-no-files-found: warn - - # # 只在 Java 17 版本上更新依赖图(权限和token已修复) - # - name: Update dependency graph - # uses: advanced-security/maven-dependency-submission-action@v4 - # if: matrix.java-version == '17' && success() - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - - # # 发送构建状态通知 - # - name: Notify Build Status - # if: always() - # uses: rtCamp/action-slack-notify@v2.2.1 - # env: - # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK || '' }} - # SLACK_CHANNEL: build-notifications - # SLACK_COLOR: ${{ job.status }} - # SLACK_TITLE: Build Status for Java ${{ matrix.java-version }} - # SLACK_MESSAGE: 'Build ${{ job.status }} on Java ${{ matrix.java-version }}' \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore deleted file mode 100644 index f6e0209..0000000 --- a/backend/.gitignore +++ /dev/null @@ -1,50 +0,0 @@ -###################################################################### -# Build Tools - -.gradle -/build/ -!gradle/wrapper/gradle-wrapper.jar - -target/ -!.mvn/wrapper/maven-wrapper.jar - -###################################################################### -# IDE - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### JRebel ### -rebel.xml - -### NetBeans ### -nbproject/private/ -build/* -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ - -###################################################################### -# Others -*.log -*.xml.versionsBackup -*.swp - -!*/build/*.java -!*/build/*.html -!*/build/*.xml - -/agileboot-admin/src/main/resources/application-prod.yml - diff --git a/backend/GoogleStyle.xml b/backend/GoogleStyle.xml index c2e1d68..1214d64 100644 --- a/backend/GoogleStyle.xml +++ b/backend/GoogleStyle.xml @@ -148,7 +148,9 @@