refactor(resource): 调整用户身份获取方法
parent
7597e9d74d
commit
477d1c0dea
|
@ -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;
|
||||
|
|
|
@ -146,8 +146,8 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
|||
List<Long> allCommentIds = collectAllCommentIds(parentComments, childComments);
|
||||
|
||||
// 5. 批量查询点赞状态(仅当用户已登录)
|
||||
Map<Long, Integer> likeStatusMap = SecurityUtils.getUserId() != null ?
|
||||
batchGetLikeStatus(allCommentIds, SecurityUtils.getUserId()) :
|
||||
Map<Long, Integer> likeStatusMap = SecurityUtils.getUserIdMax() != null ?
|
||||
batchGetLikeStatus(allCommentIds, SecurityUtils.getUserIdMax()) :
|
||||
new HashMap<>();
|
||||
|
||||
// 6. 构建评论树结构(传递点赞状态)
|
||||
|
|
|
@ -131,8 +131,8 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
|
|||
List<Long> allCommentIds = collectAllCommentIds(parentComments, childComments);
|
||||
|
||||
// 5. 批量查询点赞状态(仅当用户已登录)
|
||||
Map<Long, Integer> likeStatusMap = SecurityUtils.getUserId() != null ?
|
||||
batchGetLikeStatus(allCommentIds, SecurityUtils.getUserId()) :
|
||||
Map<Long, Integer> likeStatusMap = SecurityUtils.getUserIdMax() != 0 ?
|
||||
batchGetLikeStatus(allCommentIds, SecurityUtils.getUserIdMax()) :
|
||||
new HashMap<>();
|
||||
|
||||
// 6. 构建评论树结构(传递点赞状态)
|
||||
|
|
|
@ -236,7 +236,7 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
BeanUtil.copyProperties(modelImage, modelImageVo);
|
||||
|
||||
ModelImageLike modelImageLike = modelImageLikeService.lambdaQuery()
|
||||
.eq(ModelImageLike::getUserId, SecurityUtils.getUserId())
|
||||
.eq(ModelImageLike::getUserId, SecurityUtils.getUserIdMax())
|
||||
.eq(ModelImageLike::getModelImageId, imageId)
|
||||
.one();
|
||||
|
||||
|
@ -255,8 +255,8 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
modelImageVo.setTags(tagList);
|
||||
|
||||
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
||||
modelImageVo.setUserId(SecurityUtils.getUserId());
|
||||
modelImageVo.setUserName(SecurityUtils.getUsername());
|
||||
modelImageVo.setUserId(sysUser.getUserId());
|
||||
modelImageVo.setUserName(sysUser.getUserName());
|
||||
modelImageVo.setUserAvatar(sysUser.getAvatar());
|
||||
return modelImageVo;
|
||||
}
|
||||
|
|
|
@ -492,12 +492,12 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> 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);
|
||||
|
|
|
@ -88,13 +88,9 @@ public class SysUserAttentionServiceImpl extends ServiceImpl<SysUserAttentionMap
|
|||
@Override
|
||||
public Boolean selectAttention(Long userId) {
|
||||
|
||||
SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserId(), userId);
|
||||
SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserIdMax(), userId);
|
||||
|
||||
if (sysUserAttention == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return sysUserAttention != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -391,12 +391,12 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> 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);
|
||||
|
|
Loading…
Reference in New Issue