diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelCommentController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelCommentController.java index 0c65079..c4998ae 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelCommentController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelCommentController.java @@ -48,9 +48,9 @@ public class ModelCommentController { @RepeatSubmit @GetMapping("/modelLike") public R like(@Valid - @NotNull(message = "模型id不能为空") - @ApiParam(value = "模型id", required = true) - Long modelId) { + @NotNull(message = "模型id不能为空") + @ApiParam(value = "模型id", required = true) + Long modelId) { modelLikeService.like(modelId); return R.ok(); } @@ -73,9 +73,9 @@ public class ModelCommentController { @RepeatSubmit @GetMapping("/commentLike") public R commentLike(@Valid - @NotNull(message = "评论id不能为空") - @ApiParam(value = "评论id", required = true) - Long commentId) { + @NotNull(message = "评论id不能为空") + @ApiParam(value = "评论id", required = true) + Long commentId) { modelCommentLikeService.like(commentId); return R.ok(); } @@ -88,13 +88,13 @@ public class ModelCommentController { @GetMapping("/comment") @Valid public R> getComment(@Valid - @NotNull(message = "模型id不能为空") - @ApiParam(value = "模型id", required = true) - Long modelId, + @NotNull(message = "模型id不能为空") + @ApiParam(value = "模型id", required = true) + Long modelId, @Valid - @NotNull(message = "排序方式不能为空") - @ApiParam(value = "排序方式 0最热 1最新", required = true) - Integer sortType) { + @NotNull(message = "排序方式不能为空") + @ApiParam(value = "排序方式 0最热 1最新", required = true) + Integer sortType) { List modelCommentList = modelCommentService.getComment(modelId, sortType); return R.ok(modelCommentList); } @@ -106,9 +106,9 @@ public class ModelCommentController { @ApiOperation(value = "删除模型评论") @GetMapping("/commentDelete") public R commentDelete(@Valid - @NotNull(message = "评论id不能为空") - @ApiParam(value = "评论id", required = true) - Long commentId) { + @NotNull(message = "评论id不能为空") + @ApiParam(value = "评论id", required = true) + Long commentId) { modelCommentService.removeById(commentId); return R.ok(); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java index 470e521..3736545 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java @@ -51,9 +51,9 @@ public class ModelImageCommentController { @RepeatSubmit(interval = 1000) @GetMapping("/commentLike") public R commentLike(@Valid - @NotNull(message = "评论id不能为空") - @ApiParam(value = "评论id", required = true) - Long commentId) { + @NotNull(message = "评论id不能为空") + @ApiParam(value = "评论id", required = true) + Long commentId) { modelImageCommentLikeService.like(commentId); return R.ok(); } @@ -64,8 +64,8 @@ public class ModelImageCommentController { @ApiOperation(value = "删除图片评论") @GetMapping("/commentDelete") public R commentDelete(@Valid - @NotNull(message = "评论id不能为空") - @ApiParam(value = "评论id", required = true) Long commentId) { + @NotNull(message = "评论id不能为空") + @ApiParam(value = "评论id", required = true) Long commentId) { modelImageCommentService.removeById(commentId); return R.ok(); } @@ -77,13 +77,13 @@ public class ModelImageCommentController { @GetMapping("/comment") @Valid public R> getComment(@Valid - @NotNull(message = "图片id不能为空") - @ApiParam(value = "评论id", required = true) - Long imageId, + @NotNull(message = "图片id不能为空") + @ApiParam(value = "评论id", required = true) + Long imageId, @Valid - @NotNull(message = "排序方式不能为空") - @ApiParam(value = "排序方式 0最热 1最新", required = true) - Integer sortType) { + @NotNull(message = "排序方式不能为空") + @ApiParam(value = "排序方式 0最热 1最新", required = true) + Integer sortType) { List modelImageCommentVoList = modelImageCommentService.getComment(imageId, sortType); return R.ok(modelImageCommentVoList); } diff --git a/mcwl-common/src/main/java/com/mcwl/common/utils/SecurityUtils.java b/mcwl-common/src/main/java/com/mcwl/common/utils/SecurityUtils.java index 86885af..1c20ea6 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/utils/SecurityUtils.java +++ b/mcwl-common/src/main/java/com/mcwl/common/utils/SecurityUtils.java @@ -42,14 +42,11 @@ public class SecurityUtils public static Long getUserIdMax(){ - Long userId = null; + Long userId; try { userId = SecurityUtils.getUserId(); - if (userId == null){ - userId = 0L; - } }catch (Exception e){ - log.error(e.getMessage()); + userId = 0L; } return userId; diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentServiceImpl.java index 780706b..050e307 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelCommentServiceImpl.java @@ -146,8 +146,8 @@ public class ModelCommentServiceImpl extends ServiceImpl allCommentIds = collectAllCommentIds(parentComments, childComments); // 5. 批量查询点赞状态(仅当用户已登录) - Map likeStatusMap = SecurityUtils.getUserId() != null ? - batchGetLikeStatus(allCommentIds, SecurityUtils.getUserId()) : + Map likeStatusMap = SecurityUtils.getUserIdMax() != null ? + batchGetLikeStatus(allCommentIds, SecurityUtils.getUserIdMax()) : new HashMap<>(); // 6. 构建评论树结构(传递点赞状态) diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageCommentServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageCommentServiceImpl.java index ca556ed..b2816dc 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageCommentServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageCommentServiceImpl.java @@ -131,8 +131,8 @@ public class ModelImageCommentServiceImpl extends ServiceImpl allCommentIds = collectAllCommentIds(parentComments, childComments); // 5. 批量查询点赞状态(仅当用户已登录) - Map likeStatusMap = SecurityUtils.getUserId() != null ? - batchGetLikeStatus(allCommentIds, SecurityUtils.getUserId()) : + Map likeStatusMap = SecurityUtils.getUserIdMax() != 0 ? + batchGetLikeStatus(allCommentIds, SecurityUtils.getUserIdMax()) : new HashMap<>(); // 6. 构建评论树结构(传递点赞状态) diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageServiceImpl.java index c016bcf..a7f28bb 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageServiceImpl.java @@ -236,7 +236,7 @@ public class ModelImageServiceImpl extends ServiceImpl impl } modelProduct.setIsAttention(1); - SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), modelProduct.getUserId()); + SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserIdMax(), modelProduct.getUserId()); if (sysUserAttention == null){ modelProduct.setIsAttention(0); } - WorkFlowLike workFlowLike = modelLikeMapper.selectModelLikeById(SecurityUtils.getUserId(),modelProduct.getId()); + WorkFlowLike workFlowLike = modelLikeMapper.selectModelLikeById(SecurityUtils.getUserIdMax(),modelProduct.getId()); modelProduct.setIsLike(1); if (workFlowLike == null){ modelProduct.setIsLike(0); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java index d8b7b17..f2a5814 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java @@ -88,13 +88,9 @@ public class SysUserAttentionServiceImpl extends ServiceImpl i workFlow.setTypeList(strings); } workFlow.setIsAttention(1); - SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), workFlow.getUserId()); + SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserIdMax(), workFlow.getUserId()); if (sysUserAttention == null){ workFlow.setIsAttention(0); } - WorkFlowLike workFlowLike = workFlowLikeService.selectWorkFlowLikeById(SecurityUtils.getUserId(),workFlow.getId()); + WorkFlowLike workFlowLike = workFlowLikeService.selectWorkFlowLikeById(SecurityUtils.getUserIdMax(),workFlow.getId()); workFlow.setIsLike(1); if (workFlowLike == null){ workFlow.setIsLike(0);