标签删除和评论删除的业务处理
This commit is contained in:
parent
b71d34005d
commit
778c6fdd8f
@ -82,8 +82,7 @@ public class CommentController {
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:comment:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
commentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
commentService.deleteByAdmin(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.linfeng.common.exception.LinfengException;
|
||||
import io.linfeng.modules.admin.entity.PostEntity;
|
||||
import io.linfeng.modules.admin.service.PostService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -28,8 +32,12 @@ import io.linfeng.common.utils.R;
|
||||
@RestController
|
||||
@RequestMapping("admin/discuss")
|
||||
public class DiscussController {
|
||||
|
||||
@Autowired
|
||||
private DiscussService discussService;
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@ -82,8 +90,14 @@ public class DiscussController {
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("admin:discuss:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
discussService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
List<Integer> list = Arrays.asList(ids);
|
||||
list.forEach(id->{
|
||||
List<PostEntity> entityList = postService.lambdaQuery().eq(PostEntity::getDiscussId, id).list();
|
||||
if(entityList.size()>0){
|
||||
throw new LinfengException("请先删除该话题下的帖子");
|
||||
}
|
||||
discussService.removeById(id);
|
||||
});
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
package io.linfeng.modules.admin.controller;
|
||||
|
||||
import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
import io.linfeng.modules.app.entity.MomentEntity;
|
||||
import io.linfeng.modules.app.service.MomentService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author linfeng
|
||||
* @date 2022/1/5 16:56
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/moment")
|
||||
@Api(tags = "管理端——动态接口")
|
||||
public class MomentManageController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MomentService momentService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@ApiOperation("后台——动态分页列表")
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("app:moment:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = momentService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@ApiOperation("后台——根据id获取动态")
|
||||
@GetMapping("/info/{id}")
|
||||
@RequiresPermissions("app:moment:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
MomentEntity moment = momentService.getById(id);
|
||||
|
||||
return R.ok().put("moment", moment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation("后台——保存动态")
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("app:moment:save")
|
||||
public R save(@RequestBody MomentEntity moment){
|
||||
momentService.save(moment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation("后台——修改动态")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("app:moment:update")
|
||||
public R update(@RequestBody MomentEntity moment){
|
||||
momentService.updateById(moment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation("后台——删除动态")
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("app:moment:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
momentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -25,5 +25,6 @@ public interface CommentService extends IService<CommentEntity> {
|
||||
|
||||
List<CommentEntity> getByPid(Long pid);
|
||||
|
||||
void deleteByAdmin(List<Long> longs);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import io.linfeng.common.utils.Query;
|
||||
import io.linfeng.modules.admin.dao.CommentDao;
|
||||
import io.linfeng.modules.admin.entity.CommentEntity;
|
||||
import io.linfeng.modules.admin.service.CommentService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service("commentService")
|
||||
@ -47,4 +48,20 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管理端批量删除评论
|
||||
* @param list
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByAdmin(List<Long> list) {
|
||||
list.forEach(id->{
|
||||
this.removeById(id);
|
||||
//子评论更改展示状态为屏蔽
|
||||
this.lambdaUpdate()
|
||||
.set(CommentEntity::getStatus, 0)
|
||||
.eq(CommentEntity::getPid, id)
|
||||
.update();
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user