From 4a9a9fa60f52be1e7c91f01df54b3cbae8c11d6c Mon Sep 17 00:00:00 2001 From: baizonghao <1719256278@qq.com> Date: 星期日, 23 四月 2023 13:11:21 +0800 Subject: [PATCH] 用户导出 --- src/main/java/com/example/jz/controller/ReportController.java | 83 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/jz/controller/ReportController.java b/src/main/java/com/example/jz/controller/ReportController.java index 0b17490..46f65f9 100644 --- a/src/main/java/com/example/jz/controller/ReportController.java +++ b/src/main/java/com/example/jz/controller/ReportController.java @@ -1,23 +1,38 @@ 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.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.entity.User; +import com.example.jz.modle.vo.NewCauseVo; import com.example.jz.modle.vo.ReportListVo; +import com.example.jz.modle.vo.ReportVXVO; +import com.example.jz.service.GroupUserService; +import com.example.jz.service.MessageService; import com.example.jz.service.ReportService; +import com.example.jz.service.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; +import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.Serializable; +import java.util.Map; /** * 鎶ユ琛�(Report)琛ㄦ帶鍒跺眰 @@ -34,6 +49,12 @@ */ @Resource private ReportService reportService; + @Resource + GroupUserService groupUserService; + @Resource + MessageService messageService; + @Autowired + UserService userService; /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� @@ -60,6 +81,20 @@ return R.ok(reportService.getReportListVoById(id)); } + @GetMapping("/rejectReport/{id}") + @ApiOperation(value = "淇敼椹冲洖鍚庢帴鍙�") + public R<ReportVXVO> getOne(@PathVariable Integer id){ + ReportVXVO res = reportService.getRejectReportById(id); + return R.ok(res); + } + + @GetMapping("/rejectCauseList") + public R<NewCauseVo> rejectCauseList(@RequestParam Integer id){ + NewCauseVo res = reportService.rejectCauseList(id); + return R.ok(res); + } + + /** * 鎶ユ * @@ -84,12 +119,37 @@ return R.ok(reportService.audit(report)); } + @PostMapping("/reject") + @ApiOperation(value = "椹冲洖") + public R<Boolean> reject(@RequestBody Map map) { + return R.ok(reportService.reject((Integer) map.get("id"), (String) map.get("reason"))); + } + @ApiOperation(httpMethod = "PUT", value = "妗堜欢鍙�-鎶ユ浜哄憳-缂栬緫") @PutMapping("/updateReport") @ApiResponse(message = "鎵ц鎴愬姛", code = 200) - public R updateReport(@RequestBody Report report) { - report.setPic(null); + @Transactional(rollbackFor = Exception.class) + public R updateReport(@RequestBody AddReportDto report) { + Integer causeId = report.getCauseId(); + if(causeId==null){ + return R.failed("鍏宠仈妗堜欢涓嶈兘涓虹┖"); + } + int imgIndexFirst = report.getPic().indexOf("/img"); + int imgIndexEnd = report.getPic().length(); + if(report.getPic().indexOf("?") != -1){ + imgIndexEnd = report.getPic().indexOf("?"); + } + String pic = report.getPic().substring(imgIndexFirst + 5, imgIndexEnd); + report.setPic(pic); reportService.updateById(report); + Report one = reportService.getOne(new LambdaQueryWrapper<Report>().eq(Report::getId, report.getId())); + User user = new User(); + user.setRealName(report.getReporterName()); + user.setUserIdcard(report.getIdcard()); + user.setUserMobile(report.getMobile()); + user.setPic(pic); + user.setId(one.getUserId()); + userService.updateById(user); return R.ok(); } @@ -105,15 +165,26 @@ @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(); } - @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-鎶ユ浜哄憳-鎶ユ鏉愭枡瀵煎嚭") - @PostMapping("/exportReporter") + @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-妗堜欢褰曞叆-鎶ユ浜哄憳-鎶ユ浜哄厓瀵煎叆") + @PostMapping("/reporterUpload") @ApiResponse(message = "鎵ц鎴愬姛", code = 200) - public void exportReport(@RequestParam(value = "id") Integer id, HttpServletResponse response) { - reportService.exportReporter(id, response); + @SneakyThrows + public R uploadReporter(@RequestParam(value = "multipartFile") MultipartFile multipartFile, Integer causeId) { + reportService.loadFileReport(multipartFile,causeId); + return R.ok(); } + +// @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-鎶ユ浜哄憳-鎶ユ鏉愭枡瀵煎嚭") +// @PostMapping("/exportReporter") +// @ApiResponse(message = "鎵ц鎴愬姛", code = 200) +// public void exportReport(@RequestParam(value = "id") Integer id, HttpServletResponse response) { +// reportService.exportReporter(id, response); +// } } -- Gitblit v1.8.0