@specpow/framework 0.5.26 → 0.5.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,10 +45,9 @@
|
|
|
45
45
|
- `responseJson(HttpServletResponse resp, ResponseWrapper<T> wrapper)` → 写 JSON 错误响应
|
|
46
46
|
- `exportException(HttpServletResponse resp, Throwable e)` → 写异常为 JSON
|
|
47
47
|
|
|
48
|
-
###
|
|
49
|
-
- `
|
|
50
|
-
-
|
|
51
|
-
- `getCurrentUserId()` → 获取当前用户 ID
|
|
48
|
+
### ApplicationContextUtil (com.twsz.mom.core.utils.ApplicationContextUtil)
|
|
49
|
+
- `getUserActName()` → 获取当前登录用户名称(仅在业务逻辑中需要用户名时使用,如日志记录、业务校验)
|
|
50
|
+
- 注意:审计字段(createdBy/lastUpdatedBy)由 MyBatis-Plus MetaObjectHandler 自动填充,无需手动调用此方法设置
|
|
52
51
|
|
|
53
52
|
### IdUtil (cn.hutool.core.util.IdUtil)
|
|
54
53
|
- `fastSimpleUUID()` → 生成无横线 UUID(用于导出文件名等)
|
|
@@ -65,12 +65,18 @@
|
|
|
65
65
|
|
|
66
66
|
- 接口继承 IService<T>,实现类继承 ServiceImpl<Mapper, Entity> 并实现接口
|
|
67
67
|
- @Slf4j + @Service 注解
|
|
68
|
+
- 审计字段(createdBy/createdDate/lastUpdatedBy/lastUpdatedDate)由 MyBatis-Plus MetaObjectHandler 自动填充,禁止在代码中手动设置(包括 LambdaUpdateWrapper.set())
|
|
69
|
+
- orgId 由 TenantLineInnerInterceptor 自动注入,禁止在代码中手动设置
|
|
70
|
+
- 禁止仅为设置审计字段而导入 ApplicationContextUtil——审计字段由自动填充处理
|
|
68
71
|
- saveModel 方法: @Transactional(rollbackFor = Exception.class),id==null 调 insert,否则检查乐观锁后调 update
|
|
69
72
|
- 主子表保存模式: 先保存主表,再遍历明细列表按 opt 标记处理(1=新增, 2=修改, 3=删除)
|
|
70
73
|
- saveOrUpdateOrDelete 模式: 按 ViewModel.OPT_ADD/MODIFY/DELETE 分组,批量 saveBatch/updateBatchById/delete
|
|
71
74
|
- 乐观锁: 编辑时查库比对 lastUpdatedDate(withNano(0) 去掉纳秒),不匹配则 throw new BaseException
|
|
72
|
-
- 异常抛出: `throw new BaseException(AIHttpStatus.XXX.getCode(), AIHttpStatus.XXX.getMessage())`
|
|
75
|
+
- 异常抛出: `throw new BaseException(AIHttpStatus.XXX.getCode(), AIHttpStatus.XXX.getMessage(), param1, param2)`
|
|
73
76
|
- 带参数占位: `throw new BaseException(AIHttpStatus.XXX.getCode(), AIHttpStatus.XXX.getMessage(), param1, param2)`
|
|
77
|
+
- 异常消息必须包含具体参数值,使用 `{0}`、`{1}` 占位符(如 "库位[{0}]不存在"),禁止笼统提示(如 "库位不存在")
|
|
78
|
+
- Service 层业务校验失败必须抛 BaseException,禁止用 ResponseWrapper.ofFail/ofStatus 返回错误——全局异常处理器统一包装
|
|
79
|
+
- Service 方法返回类型: 成功用 ResponseWrapper<T> 或直接返回数据,失败一律抛异常
|
|
74
80
|
- AIHttpStatus 新增 code 规则: 取 AIHttpStatus 枚举中已有 code 最大值 + 1(maxCode + 1),禁止硬编码数字
|
|
75
81
|
- AIHttpStatus 枚举命名: 中文提示的缩写,如 "类型不能为空" → TYPE_NOT_EMPTY
|
|
76
82
|
- 禁止在 Service 中手动设置 orgId(多租户插件自动注入)
|
|
@@ -100,7 +106,7 @@
|
|
|
100
106
|
- AIHttpStatus: 枚举类,code 从已有最大值+1 递增(maxCode+1),禁止硬编码 — com.twsz.mom.core.common.AIHttpStatus
|
|
101
107
|
- BaseException: `new BaseException(AIHttpStatus.XXX.getCode(), AIHttpStatus.XXX.getMessage())` — com.twsz.mom.core.exception.BaseException
|
|
102
108
|
- PageForm<T>: size(页大小), current(页码,1-based), condition(查询条件对象) — com.twsz.mom.core.common.PageForm
|
|
103
|
-
-
|
|
109
|
+
- ApplicationContextUtil: 获取当前用户名称(getUserActName) — com.twsz.mom.core.utils.ApplicationContextUtil
|
|
104
110
|
- ExcelUtil: importExcel/export — com.twsz.mom.core.utils.ExcelUtil
|
|
105
111
|
- EasyExcel: com.alibaba.excel.EasyExcel
|
|
106
112
|
- ViewModel.OPT_ADD = "1", OPT_MODIFY = "2", OPT_DELETE = "3", OPT_NOT_MODIFY_DATE = "0"
|