refactor(mcwl): 调整作品点赞功能和异常处理
parent
b27884e889
commit
ec0c8aa32a
|
@ -91,4 +91,9 @@ public class HttpStatus
|
||||||
* 系统警告消息
|
* 系统警告消息
|
||||||
*/
|
*/
|
||||||
public static final int WARN = 601;
|
public static final int WARN = 601;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一展示错误信息
|
||||||
|
*/
|
||||||
|
public static final int SHOW_ERROR_MSG = 12202;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,9 @@ public class GlobalExceptionHandler {
|
||||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Integer code = e.getCode();
|
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());
|
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class WorkFlow {
|
||||||
* 作品点赞数量
|
* 作品点赞数量
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "作品点赞数量")
|
@ApiModelProperty(value = "作品点赞数量")
|
||||||
private Integer likeCount = 0;
|
private Integer likeNum = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,12 +60,12 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
||||||
if (Objects.nonNull(workFlowLike)) {
|
if (Objects.nonNull(workFlowLike)) {
|
||||||
if (Objects.equals(workFlowLike.getDelFlag(), "0")) {
|
if (Objects.equals(workFlowLike.getDelFlag(), "0")) {
|
||||||
workFlowLike.setDelFlag("2");
|
workFlowLike.setDelFlag("2");
|
||||||
int likeCount = workFlow.getLikeCount() - 1;
|
int likeCount = workFlow.getLikeNum() - 1;
|
||||||
likeCount = Math.max(likeCount, 0);
|
likeCount = Math.max(likeCount, 0);
|
||||||
workFlow.setLikeCount(likeCount);
|
workFlow.setLikeNum(likeCount);
|
||||||
} else {
|
} else {
|
||||||
workFlowLike.setDelFlag("0");
|
workFlowLike.setDelFlag("0");
|
||||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
|
||||||
this.addLikeAdvice(workFlow);
|
this.addLikeAdvice(workFlow);
|
||||||
}
|
}
|
||||||
// 更新点赞记录
|
// 更新点赞记录
|
||||||
|
@ -82,7 +82,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
||||||
baseMapper.insert(workFlowLike);
|
baseMapper.insert(workFlowLike);
|
||||||
|
|
||||||
// 更新图片点赞数
|
// 更新图片点赞数
|
||||||
workFlow.setLikeCount(workFlow.getLikeCount() + 1);
|
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
|
||||||
workFlowMapper.updateById(workFlow);
|
workFlowMapper.updateById(workFlow);
|
||||||
|
|
||||||
this.addLikeAdvice(workFlow);
|
this.addLikeAdvice(workFlow);
|
||||||
|
@ -119,7 +119,7 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
workFlowLikeVo.setCoverPath(workFlow.getCoverPath());
|
workFlowLikeVo.setCoverPath(workFlow.getCoverPath());
|
||||||
workFlowLikeVo.setLikeNum(workFlow.getLikeCount());
|
workFlowLikeVo.setLikeNum(workFlow.getLikeNum());
|
||||||
|
|
||||||
modelLikeVoList.add(workFlowLikeVo);
|
modelLikeVoList.add(workFlowLikeVo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,7 +395,6 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
imagePageRes.setOrderByColumn("create_time");
|
imagePageRes.setOrderByColumn("create_time");
|
||||||
}
|
}
|
||||||
// 设置排序
|
// 设置排序
|
||||||
// 设置排序
|
|
||||||
List<OrderItem> orderItemList = new ArrayList<>();
|
List<OrderItem> orderItemList = new ArrayList<>();
|
||||||
orderItemList.add(OrderItem.desc("is_top"));
|
orderItemList.add(OrderItem.desc("is_top"));
|
||||||
orderItemList.add(OrderItem.desc(imagePageRes.getOrderByColumn()));
|
orderItemList.add(OrderItem.desc(imagePageRes.getOrderByColumn()));
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="workFlowList" resultType="com.mcwl.resource.domain.response.ResponseWorkFlow">
|
<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
|
FROM work_flow as w
|
||||||
LEFT JOIN sys_user u
|
LEFT JOIN sys_user u
|
||||||
on w.user_id = u.user_id
|
on w.user_id = u.user_id
|
||||||
|
|
Loading…
Reference in New Issue