Files
training/backend/AGENTS.md
2026-07-28 11:59:31 +08:00

60 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 后端开发规则
## 技术栈
- Spring Boot 3.4.5、Java 21、MyBatis-Plus、mysql 8、redis
## 总体规则
- 代码须符合阿里巴巴Java开发规范、springboot框架规范、其他使用到的框架、中间件规范。
## 项目结构(不可变)
后端源码必须遵循以下目录结构:
```text
backend/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/training/
│ │ │ ├── TrainingApplication.java # 启动类(@SpringBootApplication
│ │ │ ├── config/ # @Configuration 配置类
│ │ │ │ ├── MybatisPlusConfig.java
│ │ │ │ └── SecurityConfig.java
│ │ │ ├── constant/ # 常量类
│ │ │ │ └── Constants.java
│ │ │ ├── enums/ # 枚举
│ │ │ │ └── UserTypeEnum.java
│ │ │ ├── controller/ # @RestControllerHTTP 入口
│ │ │ │ └── UserController.java
│ │ │ ├── service/ # @Service业务逻辑
│ │ │ │ ├── UserService.java # 接口
│ │ │ │ └── impl/UserServiceImpl.java # 实现
│ │ │ ├── mapper/ # @Mapper数据访问
│ │ │ │ └── UserMmapper.java
│ │ │ ├── domain
│ │ │ │ └── entity/ # @Entity数据库映射
│ │ │ │ └── User.java
│ │ │ │ ├── dto/ # 请求对象
│ │ │ │ └── UserDto.java
│ │ │ │ ├── vo/ # 响应对象
│ │ │ │ └── UserVo.java
│ │ │ ├── exception/ # 自定义异常 + 全局处理器
│ │ │ │ ├── ServiceException.java
│ │ │ │ └── GlobalExceptionHandler.java
│ │ │ └── util/ # 工具类
│ │ └── resources/
│ │ ├── application.yml # 主配置(也可用 .properties
│ │ ├── static/ # CSS/JS/图片等静态资源
│ │ ├── templates/ # 模板
│ │ ├── logback-spring.xml # 日志配置
│ │ └── mapper # mapper文件
│ │ └── User.xml
│ └── test/
│ └── java/com/example/training/ # 测试代码,包结构镜像 main
│ ├── MyappApplicationTests.java
│ ├── controller/UserControllerTest.java
│ └── service/UserServiceTest.java
```