From a5a0ff50ea4be9a7e7d0c6f805ed26809e3b183e Mon Sep 17 00:00:00 2001 From: shiyue <1211061228@qq.com> Date: 星期四, 16 二月 2023 12:48:42 +0800 Subject: [PATCH] 2023-02-16更新 --- src/main/java/com/example/jz/controller/ReportController.java | 130 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 103 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/example/jz/controller/ReportController.java b/src/main/java/com/example/jz/controller/ReportController.java index 7e4bdf8..a99b59c 100644 --- a/src/main/java/com/example/jz/controller/ReportController.java +++ b/src/main/java/com/example/jz/controller/ReportController.java @@ -1,44 +1,69 @@ 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.api.R; 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.ReportListVo; +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.List; /** * 鎶ユ琛�(Report)琛ㄦ帶鍒跺眰 * - * @author makejava + * @author 瀹夌懢鐒� * @since 2022-07-13 11:52:58 */ @RestController @RequestMapping("report") +@Api(value = "妗堜欢鍖�-妗堜欢浜哄憳", tags = "妗堜欢鍖�-妗堜欢浜哄憳") public class ReportController extends ApiController { /** * 鏈嶅姟瀵硅薄 */ @Resource private ReportService reportService; + @Resource + GroupUserService groupUserService; + @Resource + MessageService messageService; + @Autowired + UserService userService; /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� * - * @param page 鍒嗛〉瀵硅薄 - * @param report 鏌ヨ瀹炰綋 + * @param page 鍒嗛〉瀵硅薄 + * @param reportParamDto 鏌ヨ瀹炰綋 * @return 鎵�鏈夋暟鎹� */ @GetMapping - public R selectAll(Page<Report> page, Report report) { - return success(this.reportService.page(page, new QueryWrapper<>(report))); + @ApiOperation(value = "鍒嗛〉鏌ヨ鎵�鏈夋暟鎹�") + public R<IPage<ReportListVo>> selectAll(Page<ReportListVo> page, ReportParamDto reportParamDto) { + return R.ok(reportService.getPage(page, reportParamDto)); } /** @@ -48,41 +73,92 @@ * @return 鍗曟潯鏁版嵁 */ @GetMapping("{id}") - public R selectOne(@PathVariable Serializable id) { - return success(this.reportService.getById(id)); + @ApiOperation(value = "閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁") + public R<ReportListVo> selectOne(@PathVariable Serializable id) { + return R.ok(reportService.getReportListVoById(id)); } /** - * 鏂板鏁版嵁 + * 鎶ユ * - * @param report 瀹炰綋瀵硅薄 + * @param addReportDto 瀹炰綋瀵硅薄 * @return 鏂板缁撴灉 */ @PostMapping - public R insert(@RequestBody Report report) { - return success(this.reportService.save(report)); + @ApiOperation(value = "鎶ユ") + public R<Boolean> insert(@RequestBody AddReportDto addReportDto) { + return R.ok(reportService.addReport(addReportDto)); } /** - * 淇敼鏁版嵁 + * 瀹℃牳閫氳繃骞朵笖鍏宠仈妗堜欢id * * @param report 瀹炰綋瀵硅薄 * @return 淇敼缁撴灉 */ - @PutMapping - public R update(@RequestBody Report report) { - return success(this.reportService.updateById(report)); + @PostMapping("/audit") + @ApiOperation(value = "瀹℃牳閫氳繃") + public R<Boolean> audit(@RequestBody Report report) { + return R.ok(reportService.audit(report)); } - /** - * 鍒犻櫎鏁版嵁 - * - * @param idList 涓婚敭缁撳悎 - * @return 鍒犻櫎缁撴灉 - */ - @DeleteMapping - public R delete(@RequestParam("idList") List<Long> idList) { - return success(this.reportService.removeByIds(idList)); + @ApiOperation(httpMethod = "PUT", value = "妗堜欢鍙�-鎶ユ浜哄憳-缂栬緫") + @PutMapping("/updateReport") + @ApiResponse(message = "鎵ц鎴愬姛", code = 200) + @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().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(); + } + + @ApiOperation(httpMethod = "DELETE", value = "妗堜欢鍙�-鎶ユ浜哄憳-閫�缇�") + @DeleteMapping("/leaveGroup") + @ApiResponse(message = "鎵ц鎴愬姛", code = 200) + public R leaveGroup(@RequestParam(value = "id") Integer id, @RequestParam(value = "groupId") Integer groupId) { + reportService.leaveGroup(id, groupId); + return R.ok(); + } + + @ApiOperation(httpMethod = "DELETE", value = "妗堜欢鍙�-鎶ユ浜哄憳-鍒犻櫎") + @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("/reporterUpload") + @ApiResponse(message = "鎵ц鎴愬姛", code = 200) + @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