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/WxAppController.java |  122 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 119 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/example/jz/controller/WxAppController.java b/src/main/java/com/example/jz/controller/WxAppController.java
index 207acea..4b74b69 100644
--- a/src/main/java/com/example/jz/controller/WxAppController.java
+++ b/src/main/java/com/example/jz/controller/WxAppController.java
@@ -7,6 +7,7 @@
 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.example.jz.auth.TokenJwtManager;
 import com.example.jz.dao.UserDao;
 import com.example.jz.modle.R;
@@ -14,6 +15,9 @@
 import com.example.jz.modle.vo.*;
 import com.example.jz.service.*;
 import com.example.jz.utils.HttpUtil;
+import io.swagger.annotations.Api;
+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;
@@ -24,12 +28,15 @@
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.client.RestTemplate;
 
+import javax.annotation.Resource;
+import java.sql.Array;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/wx")
+@Api(tags = "寰俊灏忕▼搴忔帴鍙�")
 public class WxAppController {
 
     private final String wxApp_userCode_verify_url = "https://api.weixin.qq.com/sns/jscode2session";
@@ -69,6 +76,10 @@
     GroupUserService groupUserService;
     @Autowired
     PublicityService publicityService;
+    @Autowired
+    private AnnouncementService announcementService;
+    @Autowired
+    private PoliceAnnouncementService policeAnnouncementService;
 
     @GetMapping("/checkIdentity")
     public R checkIdentity(@RequestParam String code, @RequestParam String phoneNumberCode) throws Exception {
@@ -246,10 +257,11 @@
     public R addReport(@RequestBody ReportVXVO reportVXVO) {
         User user = userService.getOne(new QueryWrapper<User>().eq("id", reportVXVO.getUserId()));
         user.setRealName(reportVXVO.getRealName());
+        user.setSex(reportVXVO.getSex());
         user.setUserIdcard(reportVXVO.getUserIdCard());
         user.setLocation(reportVXVO.getLocation());
-        user.setSex(reportVXVO.getSex());
         user.setWorkingLocation(reportVXVO.getWorkingLocation());
+
         userService.update(user, new LambdaQueryWrapper<User>().eq(User::getId, user.getId()));
         Report report = new Report();
         BeanUtils.copyProperties(reportVXVO, report);
@@ -260,6 +272,59 @@
         report.setStatus(0);
         report.setReportMethod("鎵爜鎶ユ");
         return R.ok(reportService.save(report));
+    }
+
+    @PostMapping("/user/policeAddReport")
+    public R policeAddReport(@RequestBody ReportVXVO reportVXVO) {
+        User one = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getUserMobile, reportVXVO.getPhone()));
+        if (Objects.nonNull(one)){
+             return R.ok("璇ユ墜鏈哄彿宸茶娉ㄥ唽");
+        }
+
+        User user = new User();
+
+        user.setUserMobile(reportVXVO.getPhone());
+        user.setRealName(reportVXVO.getRealName());
+        user.setSex(reportVXVO.getSex());
+        user.setUserIdcard(reportVXVO.getUserIdCard());
+        user.setLocation(reportVXVO.getLocation());
+        user.setWorkingLocation(reportVXVO.getWorkingLocation());
+        user.setCtime(new Date());
+        userService.save(user);
+
+        Report report = new Report();
+        BeanUtils.copyProperties(reportVXVO, report);
+        report.setAmountInvolved(reportVXVO.getAmountInvolved());
+        report.setUserId(user.getId());
+        report.setPic(user.getPic());
+        report.setIsInGroup(0);
+        report.setCtime(new Date());
+        report.setStatus(0);
+        report.setReportMethod("鎵爜鎶ユ");
+        return R.ok(reportService.save(report));
+    }
+
+    @PutMapping ("/user/addReport")
+    public R addReport1(@RequestBody ReportVXVO reportVXVO) {
+        User user = userService.getOne(new QueryWrapper<User>().eq("id", reportVXVO.getUserId()));
+        user.setRealName(reportVXVO.getRealName());
+        user.setSex(reportVXVO.getSex());
+        user.setUserIdcard(reportVXVO.getUserIdCard());
+        user.setLocation(reportVXVO.getLocation());
+        user.setWorkingLocation(reportVXVO.getWorkingLocation());
+
+        userService.update(user, new LambdaQueryWrapper<User>().eq(User::getId, user.getId()));
+        Report report = new Report();
+        BeanUtils.copyProperties(reportVXVO, report);
+        report.setAmountInvolved(reportVXVO.getAmountInvolved());
+        report.setPic(user.getPic());
+        report.setIsInGroup(0);
+        report.setCtime(new Date());
+        report.setStatus(0);
+        report.setReportMethod("鎵爜鎶ユ");
+
+        reportService.update(report, new LambdaQueryWrapper<Report>().eq(Report::getId, report.getId()));
+        return R.ok("淇敼鎴愬姛");
     }
 
     @PostMapping("/user/add")
@@ -359,20 +424,29 @@
                     HashMap<String, Object> messageMap = new HashMap<>();
                     messageMap.put("text", item.getText());
                     messageMap.put("time", item.getCtime());
+                    messageMap.put("messageId", item.getId());
                     if (item.getUserId() != null) {
                         Report report = reportService.getOne(new QueryWrapper<Report>().eq("id", item.getUserId()));
                         User user = userService.getOne(new QueryWrapper<User>().eq("id", report.getUserId()));
+                        if (Objects.isNull(user)) {
+                            return;
+                        }
                         messageMap.put("id", user.getId());
                         messageMap.put("name", item.getReportName());
                         messageMap.put("mobile", user.getUserMobile());
                         messageMap.put("idcard", user.getUserIdcard());
+                        messageMap.put("sex", user.getSex());
                         messageMap.put("pic", user.getPic());
                         messageMap.put("role", 0);
                     } else {
                         messageMap.put("id", item.getCopId());
                         User user = userService.getOne(new QueryWrapper<User>().eq("id", item.getCopId()));
+                        if (Objects.isNull(user)) {
+                            return;
+                        }
                         messageMap.put("name", user.getRealName());
                         messageMap.put("mobile", user.getUserMobile());
+                        messageMap.put("sex", user.getSex());
                         messageMap.put("role", 1);
                     }
                     message.add(messageMap);
@@ -523,6 +597,10 @@
         if (StringUtils.isBlank(msg)) {
             return R.failed("msg is blank");
         }
+        GroupUser one = groupUserService.getOne(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getUserId, id).eq(GroupUser::getGroupId, groupId));
+        if (one.getBanSpeech() == 1){
+            return R.failed("璇ョ敤鎴峰凡缁忚绂佽█");
+        }
         Message message = new Message();
         message.setUserId(id);
         message.setText(msg);
@@ -544,20 +622,29 @@
         return R.ok(reportVo);
     }
 
+    /**
+     *
+     * @param id
+     * @return
+     */
     @GetMapping("/manager/report")
-    public R queryReport() {
-        return R.ok(reportService.list(new LambdaQueryWrapper<Report>().eq(Report::getStatus, 0))
+    public R queryReport(@RequestParam Integer id) {
+        List<Integer> collect = causeService.list(Wrappers.<Cause>lambdaQuery().eq(Cause::getUserId, id)).stream().map(cause -> cause.getId()).collect(Collectors.toList());
+        R<List<ReportVo>> ok = R.ok(reportService.list(new LambdaQueryWrapper<Report>().eq(Report::getStatus, 0).in(Report::getCauseId, collect))
                 .stream()
                 .map(item -> {
                     ReportVo reportVo = new ReportVo();
                     BeanUtils.copyProperties(item, reportVo);
                     User user = userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, item.getUserId()));
+                    Cause one = causeService.getOne(new LambdaQueryWrapper<Cause>().eq(Cause::getId, item.getCauseId()));
+                    reportVo.setReportDescription(one.getName());
                     reportVo.setReporterName(user.getRealName());
                     reportVo.setMobile(user.getUserMobile());
                     reportVo.setIdcard(user.getUserIdcard());
                     return reportVo;
                 })
                 .collect(Collectors.toList()));
+        return ok;
     }
 
     @GetMapping("/publicity")
@@ -568,4 +655,33 @@
         }
         return R.ok(publicityList);
     }
+
+    @ApiOperation(httpMethod = "POST", value = "缇ゅ叕鍛婃坊鍔�")
+    @PostMapping("/announcement/add")
+    public R insert(@RequestParam(value = "groupId") Integer groupId, @RequestParam String announcement) {
+        Announcement announcement1 = new Announcement();
+        announcement1.setText(announcement);
+        announcement1.setStatus(1);
+        return R.ok(announcementService.vxAdd(groupId, announcement1));
+    }
+
+    @ApiOperation(httpMethod = "DELETE", value = "缇ゅ叕鍛婂垹闄�")
+    @DeleteMapping("/announcement/delete")
+    public R delete(@RequestParam(value = "id") Integer id) {
+        announcementService.removeById(id);
+        return R.ok();
+    }
+
+    @ApiOperation(httpMethod = "GET", value = "鏌ョ湅缇ゅ叕鍛�")
+    @GetMapping("/getAnnouncements")
+    public R getAnnouncements(@RequestParam(value = "groupId") Integer groupId) {
+        return R.ok(announcementService.getAnnouncements(groupId));
+    }
+
+    @GetMapping("policeAnnouncement/list")
+    @ApiOperation(httpMethod = "GET", value = "璀︽柟鍏憡")
+    public R getPoliceAnnouncement(){
+        List<PoliceAnnouncement> list = policeAnnouncementService.list(Wrappers.<PoliceAnnouncement>lambdaQuery().eq(PoliceAnnouncement::getStatus, 1).orderByDesc(PoliceAnnouncement::getCtime));
+        return R.ok(list);
+    }
 }

--
Gitblit v1.8.0