diff --git a/backend/checkstyle.xml b/backend/checkstyle.xml
new file mode 100644
index 0000000..37af12a
--- /dev/null
+++ b/backend/checkstyle.xml
@@ -0,0 +1,32 @@
+
+
+
+
REQ-USR-001: 项目首个后端 REQ,初始化 Maven 骨架与公共基础设施。
+ */ +@SpringBootApplication +@MapperScan("com.xly.erp.**.mapper") +public class ErpApplication { + + public static void main(String[] args) { + SpringApplication.run(ErpApplication.class, args); + } +} diff --git a/backend/src/main/resources/application-test.yml b/backend/src/main/resources/application-test.yml new file mode 100644 index 0000000..ef9f7d1 --- /dev/null +++ b/backend/src/main/resources/application-test.yml @@ -0,0 +1,17 @@ +# application-test.yml — 测试 profile。 +# 连同一测试库(xlyweberp_vibe_erp_test,由 setup-test-db.mjs DROP+CREATE 后由 Flyway apply V1)。 +# 测试期间 Flyway 自动 apply sql/migrations/ 下的 V1+;DB 凭据沿用主配置默认(来自 config-vars.yaml)。 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${DB_HOST:118.178.19.35}:${DB_PORT:3318}/${DB_SCHEMA:xlyweberp_vibe_erp_test}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true + username: ${DB_USER:xlyprint} + password: ${DB_PASSWORD:xlyXLYprint2016} + flyway: + enabled: true + locations: filesystem:../sql/migrations + baseline-on-migrate: true + +jwt: + secret: ${JWT_SECRET:a3b7e8f1c4d6029e5b8f37a1c9d2e4068b5f1d3a7c0e9b2f48d6a1c5e7f9b3d2} + expire-millis: 43200000 diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml new file mode 100644 index 0000000..24fa4d8 --- /dev/null +++ b/backend/src/main/resources/application.yml @@ -0,0 +1,37 @@ +# application.yml — 小羚羊 ERP 后端主配置。 +# 端口 / 数据源 / MyBatis-Plus / Flyway / JWT。 +# 敏感值(DB 凭据 / JWT 密钥)通过环境变量注入,单一来源为仓库根 config-vars.yaml, +# 由工具脚本 / 部署环境导出为下列 env,禁止硬编码进源码。 +server: + port: ${BACKEND_HTTP_PORT:5172} + +spring: + application: + name: xly-erp-backend + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${DB_HOST:118.178.19.35}:${DB_PORT:3318}/${DB_SCHEMA:xlyweberp_vibe_erp_test}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true + username: ${DB_USER:xlyprint} + password: ${DB_PASSWORD:xlyXLYprint2016} + flyway: + enabled: true + locations: filesystem:../sql/migrations + baseline-on-migrate: true + table: flyway_schema_history + +mybatis-plus: + configuration: + map-underscore-to-camel-case: false + global-config: + db-config: + id-type: auto + +# JWT 配置:密钥单一来源 config-vars.yaml secrets.jwt_secret,通过 env 注入。 +jwt: + secret: ${JWT_SECRET:a3b7e8f1c4d6029e5b8f37a1c9d2e4068b5f1d3a7c0e9b2f48d6a1c5e7f9b3d2} + # 过期时间(毫秒),默认 12 小时 + expire-millis: ${JWT_EXPIRE_MILLIS:43200000} + +logging: + level: + com.xly.erp: INFO diff --git a/backend/src/test/java/com/xly/erp/ErpApplicationTests.java b/backend/src/test/java/com/xly/erp/ErpApplicationTests.java new file mode 100644 index 0000000..71776cf --- /dev/null +++ b/backend/src/test/java/com/xly/erp/ErpApplicationTests.java @@ -0,0 +1,21 @@ +package com.xly.erp; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +/** + * 骨架健康自检:证明 pom 依赖 / 启动类 / application.yml 自洽, + * Flyway 能对测试库 apply V1,MyBatis-Plus 装配成功。 + * + *REQ-USR-001 T1。
+ */ +@SpringBootTest +@ActiveProfiles("test") +class ErpApplicationTests { + + @Test + void contextLoads() { + // Spring 上下文成功加载即通过。 + } +}