# risk-decision **Repository Path**: fairwork/risk-decision ## Basic Information - **Project Name**: risk-decision - **Description**: No description available - **Primary Language**: Java - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-27 - **Last Updated**: 2026-01-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Risk Decision - 风险决策管理系统 基于 Spring Boot 3.2 的企业级风险决策管理系统脚手架。 ## 📋 项目特性 - ✅ Spring Boot 3.2 + Java 17 - ✅ Spring Data JPA + H2/MySQL - ✅ Spring Validation (参数校验) - ✅ SpringDoc OpenAPI (Swagger UI) - ✅ 全局异常处理 - ✅ 统一响应格式 - ✅ Lombok (减少样板代码) - ✅ MapStruct (对象映射) - ✅ Actuator (监控) ## 🚀 快速开始 ### 环境要求 - JDK 17+ - Maven 3.6+ ### 运行项目 ```bash # 1. 编译项目 mvn clean install # 2. 启动应用 mvn spring-boot:run # 或者直接运行主类 java -jar target/risk-decision-1.0.0.jar ``` ### 访问地址 - **应用地址**: http://localhost:8080/api - **Swagger UI**: http://localhost:8080/api/swagger-ui.html - **H2 控制台**: http://localhost:8080/api/h2-console - **健康检查**: http://localhost:8080/api/health - **Actuator**: http://localhost:8080/api/actuator/health ## 📁 项目结构 ``` risk-decision/ ├── src/ │ ├── main/ │ │ ├── java/com/example/riskdecision/ │ │ │ ├── controller/ # 控制器层 │ │ │ ├── service/ # 业务逻辑层 │ │ │ ├── repository/ # 数据访问层 │ │ │ ├── model/ # 数据模型 │ │ │ │ ├── entity/ # 实体类 │ │ │ │ ├── dto/ # 数据传输对象 │ │ │ │ └── vo/ # 视图对象 │ │ │ ├── config/ # 配置类 │ │ │ ├── exception/ # 异常处理 │ │ │ │ └── handler/ # 异常处理器 │ │ │ └── util/ # 工具类 │ │ └── resources/ │ │ ├── application.yml # 主配置文件 │ │ ├── application-dev.yml # 开发环境配置 │ │ └── application-prod.yml # 生产环境配置 │ └── test/ # 测试代码 ├── .claude/ # Claude Code Developer Kit ├── .gitignore ├── LICENSE ├── pom.xml └── README.md ``` ## 🛠️ 技术栈 | 技术 | 版本 | 说明 | |------|------|------| | Spring Boot | 3.2.0 | 核心框架 | | Spring Data JPA | 3.2.0 | ORM 框架 | | SpringDoc OpenAPI | 2.2.0 | API 文档 | | Lombok | 1.18.30 | 简化代码 | | MapStruct | 1.5.5.Final | 对象映射 | | H2 Database | - | 开发数据库 | | MySQL | 8.0+ | 生产数据库 | ## 📖 开发指南 ### 创建实体类 ```java @Entity @Data @Table(name = "rules") public class Rule { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; private String description; @CreationTimestamp private LocalDateTime createdAt; @UpdateTimestamp private LocalDateTime updatedAt; } ``` ### 创建 Repository ```java public interface RuleRepository extends JpaRepository { List findByActiveTrue(); } ``` ### 创建 Service ```java @Service @RequiredArgsConstructor public class RuleService { private final RuleRepository ruleRepository; public List getAllRules() { return ruleRepository.findAll(); } } ``` ### 创建 Controller ```java @RestController @RequestMapping("/api/rules") @RequiredArgsConstructor @Tag(name = "Rules", description = "规则管理 API") public class RuleController { private final RuleService ruleService; @GetMapping public ResponseResult> getAllRules() { return ResponseResult.success(ruleService.getAllRules()); } } ``` ## 🧪 测试 ```bash # 运行所有测试 mvn test # 运行特定测试类 mvn test -Dtest=RuleServiceTest # 查看测试覆盖率 mvn clean test jacoco:report ``` ## 🔧 配置说明 ### 开发环境 (application-dev.yml) - H2 内存数据库 - SQL 日志输出 - DEBUG 级别日志 ### 生产环境 (application-prod.yml) - MySQL 数据库 - SQL 日志关闭 - INFO 级别日志 - 文件日志输出 ### 切换环境 ```bash # 开发环境 mvn spring-boot:run -Dspring-boot.run.profiles=dev # 生产环境 mvn spring-boot:run -Dspring-boot.run.profiles=prod ``` ## 📚 API 文档 启动项目后访问 Swagger UI: http://localhost:8080/api/swagger-ui.html 所有 API 自动生成文档,支持在线测试。 ## 🔐 安全建议 1. 修改默认密码 2. 启用 Spring Security 3. 配置 CORS 4. 添加 JWT 认证 5. 输入参数验证 6. SQL 注入防护 ## 🚀 下一步计划 - [ ] 添加 Spring Security + JWT - [ ] 集成 Redis 缓存 - [ ] 添加单元测试和集成测试 - [ ] 配置 CI/CD - [ ] Docker 容器化 - [ ] 添加日志收集 - [ ] 性能优化 ## 📄 License This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details. ## 👥 Team Risk Decision Development Team --- **Made with ❤️ using Spring Boot and Claude Code**