🚑 https://github.com/rymcu/forest/issues/40
This commit is contained in:
commit
cb85e139d9
@ -67,7 +67,7 @@ public interface ArticleService extends Service<Article> {
|
||||
* @param id
|
||||
* @return
|
||||
* */
|
||||
Map delete(Integer id);
|
||||
Map delete(Integer id) throws BaseApiException;
|
||||
|
||||
/**
|
||||
* 增量文章浏览数
|
||||
|
@ -249,8 +249,18 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map delete(Integer id) {
|
||||
public Map delete(Integer id) throws BaseApiException {
|
||||
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;
|
||||
// 判断是否有评论
|
||||
boolean isHavComment = articleMapper.existsCommentWithPrimaryKey(id);
|
||||
|
@ -61,7 +61,7 @@ public class ArticleController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public GlobalResult delete(@PathVariable Integer id) {
|
||||
public GlobalResult delete(@PathVariable Integer id) throws BaseApiException {
|
||||
Map map = articleService.delete(id);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user