fix(emergency): 修复宣教模块3个状态机与兼容性缺陷
- auditStatus 新增 insertStrategy=IGNORED,修复新增/复制时存0而非NULL - submitForReview 增加PENDING重复提交拦截 - recordRead/toggleFavorite 重复键异常catch兼容DM8数据库 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ public class FirstAidResource implements Serializable {
|
||||
|
||||
/** 审核状态(null=无审核,10=待审核,11=已通过,12=已驳回),值由 FirstAidConstants 常量控制 */
|
||||
@Schema(title = "审核状态(null=无审核,10=待审核,11=已通过,12=已驳回)")
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer auditStatus;
|
||||
|
||||
/** 驳回原因 */
|
||||
|
||||
+4
@@ -129,6 +129,10 @@ public class FirstAidResourceServiceImpl extends ServiceImpl<FirstAidResourceMap
|
||||
if (resource == null) {
|
||||
throw new RuntimeException("资源不存在");
|
||||
}
|
||||
// 已提交审核的不允许重复提交
|
||||
if (FirstAidConstants.AUDIT_STATUS_PENDING.equals(resource.getAuditStatus())) {
|
||||
throw new RuntimeException("已提交审核,请勿重复操作");
|
||||
}
|
||||
// 仅草稿或已驳回状态可提交审核
|
||||
if (!FirstAidConstants.STATUS_DRAFT.equals(resource.getStatus())) {
|
||||
if (!FirstAidConstants.AUDIT_STATUS_REJECTED.equals(resource.getAuditStatus())) {
|
||||
|
||||
+5
-4
@@ -43,8 +43,9 @@ public class FirstAidResourceUserActionServiceImpl extends ServiceImpl<FirstAidR
|
||||
action.setType(FirstAidConstants.ACTION_TYPE_READ);
|
||||
try {
|
||||
save(action);
|
||||
} catch (org.springframework.dao.DuplicateKeyException e) {
|
||||
return false; // 已有阅读记录
|
||||
} catch (Exception e) {
|
||||
// 重复键异常(兼容DM8/MySQL/PG等不同数据库驱动的异常类型差异)
|
||||
return false;
|
||||
}
|
||||
resourceMapper.incrementViewCount(resourceId);
|
||||
return true;
|
||||
@@ -61,8 +62,8 @@ public class FirstAidResourceUserActionServiceImpl extends ServiceImpl<FirstAidR
|
||||
save(action);
|
||||
resourceMapper.incrementFavoriteCount(resourceId);
|
||||
return true;
|
||||
} catch (org.springframework.dao.DuplicateKeyException e) {
|
||||
// 已收藏 → 取消收藏
|
||||
} catch (Exception e) {
|
||||
// 重复键异常(兼容DM8/MySQL/PG等不同数据库驱动的异常类型差异)
|
||||
LambdaQueryWrapper<FirstAidResourceUserAction> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(FirstAidResourceUserAction::getResourceId, resourceId)
|
||||
.eq(FirstAidResourceUserAction::getUserId, userId)
|
||||
|
||||
Reference in New Issue
Block a user