library-picturebook-activity/backend-java/src/main/java/com/competition/common/exception/BusinessException.java

37 lines
896 B
Java
Raw Normal View History

Java 后端完整转写:NestJS/Prisma → Spring Boot/MyBatis-Plus ## 技术栈 - Spring Boot 3.2 + Java 17 + MyBatis-Plus 3.5 - Spring Security + JWT 认证(与 NestJS 兼容) - MapStruct + Knife4j + Druid + Hutool + FastJSON2 - 腾讯云 COS 文件上传 ## 项目规模 - 239 个 Java 文件,246 个文件总计 - 39 个实体类映射到现有数据库 - ~256 个 API 端点,与 NestJS 完全兼容 ## 模块清单 - Phase 0: 脚手架 + 基础框架(BaseEntity, Result, JWT, Security, AOP权限) - Phase 1: 认证/用户/角色/权限/租户(~35 接口) - Phase 2: 菜单/字典/配置/日志(~25 接口) - Phase 3: 赛事核心 — 赛事/报名/作品/团队/附件/公告(~46 接口) - Phase 4: 评审/计分/成果 — 评审规则/评委/分配/评分/排名/奖项/发布(~52 接口) - Phase 5: 作业 — 作业/提交/评分/评审规则(~20 接口) - Phase 6: 公众端 — 注册/登录/画廊/活动/作品库/子女/互动/内容审核(~55 接口) - Phase 7: UGC — 作品/绘本页/标签/点赞/收藏/评论/举报/审核日志(~15 接口) - Phase 8: 文件上传/OSS(1 接口) ## 验证结果 - mvn compile 零错误,1.8秒启动 - 62 个 API 端点手动测试通过(GET + POST/PATCH/DELETE) - 20 个前端页面 Playwright 自动化测试通过,69+ API 调用零错误 - 核心业务全流程验证:登录→赛事→报名→作品→评审→计分→排名→奖项→发布 ## 数据库适配 - 使用现有表名(Flyway 暂禁用,待正式切换时启用) - Flyway V1/V2 迁移脚本已准备(表重命名+新审计字段) - 修复:configs/t_contest_registration 添加 valid_state 列 - 修复:所有表 modify_time 添加 DEFAULT CURRENT_TIMESTAMP Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:05:41 +08:00
package com.competition.common.exception;
import com.competition.common.enums.ErrorCode;
import lombok.Getter;
/**
* 业务异常
*/
@Getter
public class BusinessException extends RuntimeException {
private final Integer code;
public BusinessException(Integer code, String message) {
super(message);
this.code = code;
}
public BusinessException(ErrorCode errorCode) {
super(errorCode.getMessage());
this.code = errorCode.getCode();
}
public BusinessException(ErrorCode errorCode, String message) {
super(message);
this.code = errorCode.getCode();
}
public static BusinessException of(ErrorCode errorCode) {
return new BusinessException(errorCode);
}
public static BusinessException of(ErrorCode errorCode, String message) {
return new BusinessException(errorCode, message);
}
}