refactor(mcwl): 调整作品点赞功能和异常处理

master
yang 2025-03-11 17:27:20 +08:00
parent b27884e889
commit ec0c8aa32a
6 changed files with 15 additions and 8 deletions

View File

@ -91,4 +91,9 @@ public class HttpStatus
*
*/
public static final int WARN = 601;
/**
*
*/
public static final int SHOW_ERROR_MSG = 12202;
}

View File

@ -85,6 +85,9 @@ public class GlobalExceptionHandler {
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
log.error(e.getMessage(), e);
Integer code = e.getCode();
if (e.getCause() instanceof RedisCommandTimeoutException) {
return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG, "网络超时,请稍后重试");
}
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
}

View File

@ -159,7 +159,7 @@ public class WorkFlow {
*
*/
@ApiModelProperty(value = "作品点赞数量")
private Integer likeCount = 0;
private Integer likeNum = 0;
/**

View File

@ -60,12 +60,12 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
if (Objects.nonNull(workFlowLike)) {
if (Objects.equals(workFlowLike.getDelFlag(), "0")) {
workFlowLike.setDelFlag("2");
int likeCount = workFlow.getLikeCount() - 1;
int likeCount = workFlow.getLikeNum() - 1;
likeCount = Math.max(likeCount, 0);
workFlow.setLikeCount(likeCount);
workFlow.setLikeNum(likeCount);
} else {
workFlowLike.setDelFlag("0");
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
this.addLikeAdvice(workFlow);
}
// 更新点赞记录
@ -82,7 +82,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
baseMapper.insert(workFlowLike);
// 更新图片点赞数
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
workFlowMapper.updateById(workFlow);
this.addLikeAdvice(workFlow);
@ -119,7 +119,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
continue;
}
workFlowLikeVo.setCoverPath(workFlow.getCoverPath());
workFlowLikeVo.setLikeNum(workFlow.getLikeCount());
workFlowLikeVo.setLikeNum(workFlow.getLikeNum());
modelLikeVoList.add(workFlowLikeVo);
}

View File

@ -395,7 +395,6 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
imagePageRes.setOrderByColumn("create_time");
}
// 设置排序
// 设置排序
List<OrderItem> orderItemList = new ArrayList<>();
orderItemList.add(OrderItem.desc("is_top"));
orderItemList.add(OrderItem.desc(imagePageRes.getOrderByColumn()));

View File

@ -44,7 +44,7 @@
</select>
<select id="workFlowList" resultType="com.mcwl.resource.domain.response.ResponseWorkFlow">
SELECT id,w.user_id,workflow_name,type,use_number,download_number,cover_path,like_count,nick_name,avatar
SELECT id,w.user_id,workflow_name,type,use_number,download_number,cover_path,like_num,nick_name,avatar
FROM work_flow as w
LEFT JOIN sys_user u
on w.user_id = u.user_id