青羊经侦大队-数据平台
wl
2022-12-27 8b26fa15912e355e57990946ac52f699130788c2
fix: 删除管理删除用户删除案件
3个文件已修改
47 ■■■■■ 已修改文件
src/main/java/com/example/jz/controller/ReportController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/controller/UserController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/service/impl/CauseServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/controller/ReportController.java
@@ -1,14 +1,19 @@
package com.example.jz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.jz.modle.R;
import com.example.jz.modle.dto.AddReportDto;
import com.example.jz.modle.dto.ReportParamDto;
import com.example.jz.modle.entity.GroupUser;
import com.example.jz.modle.entity.Message;
import com.example.jz.modle.entity.Report;
import com.example.jz.modle.vo.ReportListVo;
import com.example.jz.service.GroupUserService;
import com.example.jz.service.MessageService;
import com.example.jz.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -34,6 +39,10 @@
     */
    @Resource
    private ReportService reportService;
    @Resource
    GroupUserService groupUserService;
    @Resource
    MessageService messageService;
    /**
     * 分页查询所有数据
@@ -105,6 +114,8 @@
    @DeleteMapping("/deleteReporter")
    @ApiResponse(message = "执行成功", code = 200)
    public R deleteReporter(@RequestParam(value = "id") Integer id) {
        groupUserService.remove(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getUserId, id));
        messageService.remove(new LambdaQueryWrapper<Message>().eq(Message::getUserId, id));
        reportService.removeById(id);
        return R.ok();
    }
src/main/java/com/example/jz/controller/UserController.java
@@ -1,5 +1,6 @@
package com.example.jz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -7,8 +8,8 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.jz.modle.R;
import com.example.jz.modle.dto.ManagerDto;
import com.example.jz.modle.entity.User;
import com.example.jz.service.UserService;
import com.example.jz.modle.entity.*;
import com.example.jz.service.*;
import com.example.jz.utils.Md5Utils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -30,6 +31,15 @@
@Api(tags = "用户管理")
public class UserController extends ApiController {
    private UserService userService;
    @Autowired
    ReportService reportService;
    @Autowired
    GroupUserService groupUserService;
    @Autowired
    MessageService messageService;
    @Autowired
    CauseService causeService;
    @Autowired
    public void setUserService(UserService userService) {
@@ -93,6 +103,14 @@
    @DeleteMapping
    @ApiOperation("删除用户数据")
    public R delete(@RequestParam("id") Integer id) {
        reportService
                .list(new LambdaQueryWrapper<Report>().eq(Report::getUserId, id))
                .stream()
                .forEach(item -> {
                    groupUserService.remove(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getUserId, item.getId()));
                    messageService.remove(new LambdaQueryWrapper<Message>().eq(Message::getUserId, item.getId()));
                });
        reportService.remove(new LambdaQueryWrapper<Report>().eq(Report::getUserId, id));
        return R.ok(this.userService.removeById(id));
    }
@@ -112,6 +130,10 @@
    @DeleteMapping("/manager")
    @ApiOperation("删除管理")
    public R removeManager(@RequestParam Integer id) {
        causeService.list(new LambdaQueryWrapper<Cause>().eq(Cause::getUserId, id)).forEach(item -> {
            causeService.deleteCause(item.getId());
        });
        messageService.remove(new LambdaQueryWrapper<Message>().eq(Message::getCopId, id));
        return R.ok(userService.removeById(id));
    }
src/main/java/com/example/jz/service/impl/CauseServiceImpl.java
@@ -58,7 +58,8 @@
    UserService userService;
    @Resource
    ReportService reportService;
    @Resource
    MessageDao messageDao;
    @Resource
    AnnouncementDao announcementDao;
@@ -203,6 +204,11 @@
    @Override
    public void deleteCause(Integer id) {
        causeDao.deleteById(id);
        Group group = groupDao.selectOne(new LambdaQueryWrapper<Group>().eq(Group::getCauseId, id));
        if (group!=null){
            messageDao.delete(new LambdaQueryWrapper<Message>().eq(Message::getGroupId,group.getId()));
            groupUserDao.delete(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getGroupId,group.getId()));
        }
        groupDao.delete(new QueryWrapper<Group>().eq("cause_id", id));
    }
@@ -288,7 +294,7 @@
                .setCreator(userDao.selectOne(new QueryWrapper<User>().eq("login_username",  SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId())
                .setUserId(user.getId())
                .setCtime(new Date())
                .setStatus(0)
                .setStatus(1)
                .setReportMethod("后台录入")
                .setIsCommission("0").setReportTime(new Date())
                .setCauseId(addReportDto.getCauseId());