This commit is contained in:
parent
a9be5d50fe
commit
00a82ff67e
@ -67,7 +67,7 @@ public interface ArticleService extends Service<Article> {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
* */
|
* */
|
||||||
Map delete(Integer id);
|
Map delete(Integer id) throws BaseApiException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增量文章浏览数
|
* 增量文章浏览数
|
||||||
|
@ -249,8 +249,18 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map delete(Integer id) {
|
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();
|
||||||
|
Integer roleWeights = userService.findRoleWeightsByUser(user.getIdUser());
|
||||||
|
if (roleWeights > 2) {
|
||||||
|
Article article = articleMapper.selectByPrimaryKey(id);
|
||||||
|
if (!user.getIdUser().equals(article.getArticleAuthorId())) {
|
||||||
|
map.put("message", "非法访问!");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
Integer result;
|
Integer result;
|
||||||
// 判断是否有评论
|
// 判断是否有评论
|
||||||
boolean isHavComment = articleMapper.existsCommentWithPrimaryKey(id);
|
boolean isHavComment = articleMapper.existsCommentWithPrimaryKey(id);
|
||||||
|
@ -61,7 +61,7 @@ public class ArticleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public GlobalResult delete(@PathVariable Integer id) {
|
public GlobalResult delete(@PathVariable Integer id) throws BaseApiException {
|
||||||
Map map = articleService.delete(id);
|
Map map = articleService.delete(id);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user