🎨 优化代码

master
linhaojun 3 years ago
parent 136265193e
commit 8d3685bb22

@ -22,6 +22,6 @@ public class RedisPrefixConstant {
public static final String LOGIN_USER = "login_user";
public static final String USER_ARTICLE_ACCESS = "article_access";
public static final String ARTICLE_ACCESS = "article_access";
}

@ -52,8 +52,8 @@ public class ArticleController {
}
@ApiOperation("根据id获取文章")
@GetMapping("/articles/{id}")
public ResultVO<ArticleDTO> getArticleById(@PathVariable("id") Integer articleId) {
@GetMapping("/articles/{articleId}")
public ResultVO<ArticleDTO> getArticleById(@PathVariable("articleId") Integer articleId) {
return ResultVO.ok(articleService.getArticleById(articleId));
}

@ -123,7 +123,7 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
if (articleForCheck.getStatus().equals(2)) {
Boolean isAccess;
try {
isAccess = redisService.sIsMember(USER_ARTICLE_ACCESS + ":" + UserUtil.getUserDetailsDTO().getId(), articleId);
isAccess = redisService.sIsMember(ARTICLE_ACCESS + ":" + UserUtil.getUserDetailsDTO().getId(), articleId);
} catch (Exception exception) {
throw new BizException(ARTICLE_ACCESS_FAIL);
}
@ -167,7 +167,7 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
throw new BizException("文章不存在");
}
if (article.getPassword().equals(articlePasswordVO.getArticlePassword())) {
redisService.sAdd(USER_ARTICLE_ACCESS + ":" + UserUtil.getUserDetailsDTO().getId(), articlePasswordVO.getArticleId());
redisService.sAdd(ARTICLE_ACCESS + ":" + UserUtil.getUserDetailsDTO().getId(), articlePasswordVO.getArticleId());
} else {
throw new BizException("密码错误");
}

Loading…
Cancel
Save