🎨 删除无效代码
This commit is contained in:
parent
8b09370cf2
commit
8795621531
@ -143,7 +143,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
if (DEFAULT_STATUS.equals(newArticle.getArticleStatus())) {
|
if (DEFAULT_STATUS.equals(newArticle.getArticleStatus())) {
|
||||||
isUpdate = true;
|
isUpdate = true;
|
||||||
}
|
}
|
||||||
if (!user.getIdUser().equals(newArticle.getArticleAuthorId())) {
|
if (!isAuthor(newArticle.getArticleAuthorId())) {
|
||||||
map.put("message", "非法访问!");
|
map.put("message", "非法访问!");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -237,13 +237,9 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map delete(Integer id) throws BaseApiException {
|
public Map delete(Integer id) throws BaseApiException {
|
||||||
Map<String, String> map = new HashMap(1);
|
Map<String, String> map = new HashMap(1);
|
||||||
// 鉴权
|
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
|
||||||
if (Objects.isNull(user)) {
|
|
||||||
throw new BaseApiException(ErrorCode.INVALID_TOKEN);
|
|
||||||
}
|
|
||||||
Article article = articleMapper.selectByPrimaryKey(id);
|
Article article = articleMapper.selectByPrimaryKey(id);
|
||||||
if (!user.getIdUser().equals(article.getArticleAuthorId())) {
|
// 鉴权
|
||||||
|
if (!isAuthor(article.getArticleAuthorId())) {
|
||||||
map.put("message", "非法访问!");
|
map.put("message", "非法访问!");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -327,10 +323,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
Map map = new HashMap(2);
|
Map map = new HashMap(2);
|
||||||
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
||||||
if (Objects.nonNull(article)) {
|
if (Objects.nonNull(article)) {
|
||||||
article.setArticleTags(tags);
|
if (isAuthor(article.getArticleAuthorId())) {
|
||||||
articleMapper.updateArticleTags(idArticle, tags);
|
article.setArticleTags(tags);
|
||||||
tagService.saveTagArticle(article, "");
|
articleMapper.updateArticleTags(idArticle, tags);
|
||||||
map.put("success", true);
|
tagService.saveTagArticle(article, "");
|
||||||
|
map.put("success", true);
|
||||||
|
} else {
|
||||||
|
map.put("success", false);
|
||||||
|
map.put("message", "非法访问!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
map.put("success", false);
|
map.put("success", false);
|
||||||
map.put("message", "更新失败,文章不存在!");
|
map.put("message", "更新失败,文章不存在!");
|
||||||
@ -338,6 +339,14 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAuthor(Integer idUser) throws BaseApiException {
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
if (Objects.nonNull(user)) {
|
||||||
|
return user.getIdUser().equals(idUser);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map updatePerfect(Integer idArticle, String articlePerfect) {
|
public Map updatePerfect(Integer idArticle, String articlePerfect) {
|
||||||
Map map = new HashMap(2);
|
Map map = new HashMap(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user