| | |
| | | |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | for (String id : ids) { |
| | | if (isPublishNews(id)){ |
| | | return Result.error("存在新闻已发布删除前请下架该新闻!"); |
| | | } |
| | | } |
| | | |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | public Boolean isPublishNews(String id){ |
| | | News entity = baseMapper.selectById(id); |
| | | return entity.getPublish(); |
| | | } |
| | | @Override |
| | | public Result removeById(String id) { |
| | | //判断是否发布发布则提示先下架,再删除 |
| | | News entity = baseMapper.selectById(id); |
| | | if(entity.getPublish()){ |
| | | throw new RuntimeException("该新闻已发布"); |
| | | if(isPublishNews(id)){ |
| | | return Result.error("该新闻已发布删除前请下架该新闻!"); |
| | | } |
| | | |
| | | baseMapper.deleteById(id); |