From 1c3f11dfd7493a4c4a8d41e2499477840bcc070c Mon Sep 17 00:00:00 2001
From: baizonghao <1719256278@qq.com>
Date: 星期五, 19 五月 2023 15:01:46 +0800
Subject: [PATCH] 限制文件大小,用户,报案人审核筛选

---
 src/main/java/com/example/jz/controller/CauseController.java |  127 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 115 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/example/jz/controller/CauseController.java b/src/main/java/com/example/jz/controller/CauseController.java
index 2609aba..d92402d 100644
--- a/src/main/java/com/example/jz/controller/CauseController.java
+++ b/src/main/java/com/example/jz/controller/CauseController.java
@@ -1,16 +1,42 @@
 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.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.api.ApiController;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.example.jz.dao.GroupDao;
+import com.example.jz.dao.GroupUserDao;
+import com.example.jz.dao.MessageDao;
+import com.example.jz.dao.ReportDao;
 import com.example.jz.modle.R;
-import com.example.jz.modle.dto.CauseDto;
+import com.example.jz.modle.dto.*;
+import com.example.jz.modle.entity.Cause;
+import com.example.jz.modle.entity.GroupUser;
+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.service.CauseService;
+import com.example.jz.service.GroupService;
+import com.example.jz.service.ReportService;
+import com.example.jz.utils.EasyExcelUtils;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
+import lombok.SneakyThrows;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 妗堜欢琛�(Cause)琛ㄦ帶鍒跺眰
@@ -27,58 +53,135 @@
      */
     @Resource
     private CauseService causeService;
+    private ReportService reportService;
 
-    @ApiOperation(httpMethod = "POST", value = "娣诲姞妗堜欢")
+    @Autowired
+    public void setReportService(ReportService reportService) {
+        this.reportService = reportService;
+    }
+
+    @Autowired
+    public void setCauseService(CauseService causeService) {
+        this.causeService = causeService;
+    }
+
+
+    @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-妗堜欢褰曞叆-娣诲姞妗堜欢")
     @PostMapping("/addCause")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
-    public R addCause(@RequestBody CauseDto causeDto) {
+    public R addCause(@RequestBody @Validated CauseDto causeDto) {
+        int count = causeService.count(new LambdaQueryWrapper<Cause>().eq(Cause::getName, causeDto.getName()));
+        if(count>0){
+            return R.failed("璇ユ浠跺悕宸插瓨鍦�,璇烽噸鏂拌緭鍏�");
+        }
         causeService.addCause(causeDto);
         return R.ok();
     }
 
-    @ApiOperation(httpMethod = "PUT", value = "淇敼妗堜欢")
+    @ApiOperation(httpMethod = "PUT", value = "妗堜欢鍙�-妗堜欢褰曞叆-淇敼妗堜欢")
     @PutMapping("/updateCause")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
-    public R updateCause(@RequestBody CauseDto causeDto,Integer id) {
-        return R.ok(causeService.updateCause(causeDto,id));
+    public R updateCause(@RequestBody @Validated CauseDto causeDto, Integer id) {
+        return R.ok(causeService.updateCause(causeDto, id));
     }
 
 
-    @ApiOperation(httpMethod = "GET", value = "妗堜欢褰曞叆鍒楄〃")
+    @ApiOperation(httpMethod = "GET", value = "妗堜欢鍙�-妗堜欢褰曞叆-妗堜欢褰曞叆鍒楄〃")
     @GetMapping("/getCauseList")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
     public R getCauseList(String cause, Integer status, Integer size, Integer current) {
         return R.ok(causeService.getCauserListByCondition(cause, status, size, current));
     }
 
-    @ApiOperation(httpMethod = "GET", value = "璐熻矗浜烘煡璇�")
+    @GetMapping("/getVxCauseList")
+    @ApiOperation(httpMethod = "GET", value = "寰俊鎵炬浠�")
+    public R<List<NewCauseVo>> getVxCauseList(@RequestParam String phone){
+        List<NewCauseVo> res =  causeService.getVxCauseList(phone);
+        return R.ok(res);
+    }
+
+    @ApiOperation(httpMethod = "GET", value = "妗堜欢鍙�-妗堜欢褰曞叆-妗堜欢褰曞叆鍒楄〃")
+    @GetMapping("/getCause")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    public R getCause(String cause, Integer status, Integer size, Integer current,Integer id) {
+        return R.ok(causeService.getCauserListByCondition(cause, status, size, current,id));
+    }
+    @ApiOperation(httpMethod = "GET", value = "妗堜欢鍙�-妗堜欢褰曞叆-璐熻矗浜烘煡璇�")
     @GetMapping("/getManagerList")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
     public R getManagerList() {
         return R.ok(causeService.getManagerList());
     }
 
-    @ApiOperation(httpMethod = "GET", value = "鑾峰彇鎶ユ浜哄憳")
+    @ApiOperation(httpMethod = "GET", value = "妗堜欢鍙�-妗堜欢褰曞叆-鑾峰彇妗堜欢鎶ユ浜哄憳")
     @GetMapping("/getReporterList")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
     public R getReporterList(Integer causeId) {
         return R.ok(causeService.getReporterList(causeId));
     }
 
-    @ApiOperation(httpMethod = "GET", value = "鑾峰彇妗堜欢缇ゅ叕鍛�")
+    @PostMapping("/exp")
+    @ApiImplicitParam(name = "causeId", value = "妗堜欢id", required = true, dataType = "Integer")
+    @ApiOperation(httpMethod = "POST", value = "缇ゆ垚鍛樹俊鎭鍑�")
+    public void ReporterListExp(@RequestParam Integer causeId,HttpServletResponse response){
+        Cause one = causeService.getOne(Wrappers.<Cause>lambdaQuery().eq(Cause::getId, causeId));
+        List<CauseReportExpDto> res = causeService.getExpList(causeId);
+        String sheetName = "鐢ㄦ埛瀵煎嚭";
+        EasyExcelUtils.export1(response, sheetName, CauseReportExpDto.class, res, one.getName() + "妗堜欢鐢ㄦ埛瀵煎嚭");
+    }
+
+    @ApiOperation(httpMethod = "GET", value = "妗堜欢鍙�-妗堜欢褰曞叆-鑾峰彇妗堜欢缇ゅ叕鍛�")
     @GetMapping("/getGroupAnnouncement")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
     public R getGroupAnnouncement(Integer groupId) {
         return R.ok(causeService.getGroupAnnouncement(groupId));
     }
 
-    @ApiOperation(httpMethod = "DELETE", value = "妗堜欢鍒犻櫎")
+    @ApiOperation(httpMethod = "DELETE", value = "妗堜欢鍙�-妗堜欢褰曞叆-妗堜欢鍒犻櫎")
     @DeleteMapping("/deleteCause")
     @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
     public R deleteCause(@RequestParam(value = "id") Integer id) {
         causeService.deleteCause(id);
         return R.ok();
     }
-    // TODO: 2022/7/15 瀵煎叆
+
+    @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-妗堜欢褰曞叆-妗堜欢瀵煎叆")
+    @PostMapping("/upload")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    @SneakyThrows
+    public R upload(@RequestParam(value = "multipartFile") MultipartFile multipartFile) {
+        causeService.loadFile(multipartFile);
+        return R.ok();
+    }
+
+    @ApiOperation(httpMethod = "POST", value = "妗堜欢鍙�-妗堜欢褰曞叆-鎶ユ浜哄憳-鎶ユ浜哄厓瀵煎叆")
+    @PostMapping("/reporterUpload")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    @SneakyThrows
+    public R uploadReporter(@RequestParam(value = "multipartFile") MultipartFile multipartFile,Integer causeId) {
+            causeService.loadFileReport(multipartFile,causeId);
+        return R.ok();
+    }
+
+    @ApiOperation(httpMethod = "GET", value = "鏍规嵁缇ょ粍id鏌ヨ妗堜欢鍒嗛〉")
+    @GetMapping("/getAllReportList")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    public R<IPage<ReportListVo>> get(Page<ReportListVo> page, ReportParamDto reportParamDto, Integer causeId) {
+        return R.ok(reportService.getPageByGroupId(page, reportParamDto, causeId));
+    }
+
+    @ApiOperation(httpMethod = "POST", value = "娣诲姞浜哄憳")
+    @PostMapping("/addReporter")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    public R<Boolean> get(@RequestBody AddReportDto addReportDto) {
+        return R.ok(causeService.addReportPeople(addReportDto));
+    }
+
+    @ApiOperation(httpMethod = "GET", value = "鑾峰彇妗堜欢鐨刬d鍜屽悕绉板垪琛�")
+    @GetMapping("/getCauseIdAndName")
+    @ApiResponse(message = "鎵ц鎴愬姛", code = 200)
+    public R getCauseIdAndName() {
+        return R.ok(causeService.getCauseIdAndName());
+    }
 }
 

--
Gitblit v1.8.0