- 新增 UserRegisterDTO 及 /user/register 接口 - 集成 MailerSend,异步发送 6 位验证码邮件 - 添加 RedisUtil 缓存验证码 10 分钟 - 补充 SEND_MAIL_FAILED、CONFIRM_PASSWORD_NOT_MATCH 错误码 - 关闭 Spring Security CSRF 与表单登录,放行 /user/register - AppleService 移除 @AllArgsConstructor,改用 @Resource 注入
3.1 KiB
3.1 KiB
Repository Guidelines
Project Structure & Module Organization
- Entrypoint
src/main/java/com/yolo/keyborad/MyApplication.java; feature code organized by layer:controller(REST),service(business),mapper(MyBatis mappers),model/common/constantfor DTOs, responses, and constants, plusconfig,aop,annotation,Interceptor, andutilsfor cross-cutting concerns. - Resource configs live in
src/main/resources:application.ymlwithapplication-dev.yml/application-prod.ymlprofiles, mapper XML files undermapper/, and platform keys/certs (Apple, mail, storage). Keep secrets out of commits. - Tests belong in
src/test/java/com/yolo/keyborad/...mirroring package names; add fixtures alongside tests when needed.
Build, Test, and Development Commands
./mvnw clean install— full build with tests; requires JDK 17../mvnw test— run test suite only../mvnw spring-boot:run -Dspring-boot.run.profiles=dev— start the API with the dev profile (loadsapplication-dev.yml)../mvnw clean package -DskipTests— create an artifact when tests are already covered elsewhere.
Coding Style & Naming Conventions
- Java 17, Spring Boot 3.5, MyBatis/MyBatis-Plus; prefer Lombok for boilerplate (
@Data,@Builder) and constructor injection for services. - Use 4-space indentation, lowercase package names,
UpperCamelCasefor classes,lowerCamelCasefor fields/params. - Controllers end with
*Controller, services with*Service, mapper interfaces with*Mapper, and request/response DTOs undermodelorcommonwith clear suffixes likeRequest/Response. - Keep configuration isolated in
config; shared constants inconstant; AOP/logging inaop; custom annotations inannotation.
Testing Guidelines
- Use Spring Boot Test + JUnit (via
spring-boot-starter-test, JUnit 4/5 support) and MockMvc/WebTestClient for HTTP layers when practical. - Name classes
*Testand align packages with the code under test. Cover service logic, mappers, and controller contracts (status + payload shape). - For data-access tests, use in-memory setups or dedicated test containers and clean up test data.
Commit & Pull Request Guidelines
- Follow the existing conventional style seen in history (e.g.,
feat(user): add email registration); keep scope lowercase and concise. - PRs should describe the change, list validation steps/commands run, call out config/profile impacts, and link issues/tasks. Add screenshots or sample requests/responses for API-facing changes when helpful.
- Ensure secrets (p8 certificates, Mailgun keys, AWS creds) are never committed; rely on environment variables or local config overrides.
Security & Configuration Tips
- Activate the intended profile via
SPRING_PROFILES_ACTIVEor-Dspring-boot.run.profiles. Keepapplication-dev.ymllocal-only; never hardcode production endpoints or credentials. - Validate signing/encryption helpers (
SignInterceptor, JWT, Apple receipt validation) with representative non-production keys before merging. - Log only necessary context; avoid logging tokens, receipts, or PII.