| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.ManagerDto; |
| | | import com.example.jz.modle.dto.UserExpDto; |
| | | import com.example.jz.modle.entity.*; |
| | | import com.example.jz.service.*; |
| | | import com.example.jz.utils.EasyExcelUtils; |
| | | import com.example.jz.utils.Md5Utils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户表(User)表控制层 |
| | |
| | | } |
| | | |
| | | @DeleteMapping("/manager") |
| | | @ApiOperation("删除管理") |
| | | @ApiOperation("删除管理人员") |
| | | public R removeManager(@RequestParam Integer id) { |
| | | causeService.list(new LambdaQueryWrapper<Cause>().eq(Cause::getUserId, id)).forEach(item -> { |
| | | causeService.deleteCause(item.getId()); |
| | | }); |
| | | List<Cause> list = causeService.list(new LambdaQueryWrapper<Cause>().eq(Cause::getUserId, id)); |
| | | if (!Objects.isNull(list) && list.size() != 0){ |
| | | ArrayList<Map> maps = new ArrayList<>(); |
| | | for (Cause cause : list) { |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("caseName", cause.getName()); |
| | | map.put("caseNumber", cause.getNumber()); |
| | | maps.add(map); |
| | | } |
| | | return R.failed(maps, "该警员还有案件关联,若要删除请先修改对应案件关联的警员"); |
| | | } |
| | | // causeService.list(new LambdaQueryWrapper<Cause>().eq(Cause::getUserId, id)).forEach(item -> { |
| | | // causeService.deleteCause(item.getId()); |
| | | // }); |
| | | // userService.remove(new LambdaQueryWrapper<User>().eq(User::getId, id)); |
| | | messageService.remove(new LambdaQueryWrapper<Message>().eq(Message::getCopId, id)); |
| | | return R.ok(userService.removeById(id)); |
| | | } |
| | | |
| | | @DeleteMapping("/crowd") |
| | | @ApiOperation("删除普通用户") |
| | | public R removeCrowd(@RequestParam Integer id){ |
| | | List<Report> list = reportService.list(Wrappers.<Report>lambdaQuery().eq(Report::getUserId, id)); |
| | | for (Report report : list) { |
| | | groupUserService.remove(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getUserId, report.getId())); |
| | | messageService.remove(new LambdaQueryWrapper<Message>().eq(Message::getUserId, report.getId())); |
| | | reportService.removeById(report.getId()); |
| | | } |
| | | userService.remove(Wrappers.<User>lambdaQuery().eq(User::getId, id)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/manager") |
| | |
| | | user.setRole(1); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("用户信息导出") |
| | | @PostMapping("/exp") |
| | | public void UserExp(HttpServletResponse response){ |
| | | List<User> list = userService.list(Wrappers.<User>lambdaQuery().eq(User::getRole, 0).eq(User::getStatus, 1)); |
| | | List<UserExpDto> userExpDtos = list.stream().map(user -> { |
| | | UserExpDto userExpDto = new UserExpDto(); |
| | | BeanUtils.copyProperties(user, userExpDto); |
| | | return userExpDto; |
| | | }).collect(Collectors.toList()); |
| | | String sheetName = "用户导出"; |
| | | EasyExcelUtils.export1(response, sheetName, UserExpDto.class, userExpDtos, "用户导出"); |
| | | } |
| | | } |