From a0dde8aa21d8bc2b55ccbb2278fc730f75f7ef8b Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 18 七月 2025 08:55:13 +0800
Subject: [PATCH] zjh20250718

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java |   87 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 80 insertions(+), 7 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java
index 055b786..7ca2360 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java
@@ -12,6 +12,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ltkj.common.annotation.Excel;
 import com.ltkj.common.core.domain.entity.SysDept;
+import com.ltkj.common.utils.SecurityUtils;
 import com.ltkj.common.utils.StringUtils;
 import com.ltkj.common.utils.poi.ExcelUtil;
 import com.ltkj.framework.config.UserHoder;
@@ -115,7 +116,7 @@
 
     @GetMapping("/getKjTjAdviceKjbqBySex")
     @ApiOperation(value = "鏍规嵁浣撴浜烘�у埆鍜屾槸鍚︿负鎬绘鏌ヨ浣撴寤鸿鎺ュ彛")
-    public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam String sex, @RequestParam @ApiParam(value = "1甯歌鍖荤敓 0鎬绘") String isZj,
+    public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam @ApiParam(value = "1甯歌鍖荤敓 0鎬绘") String isZj,
                                              @RequestParam(required = false) @ApiParam(value ="寤鸿鍐呭") String jynr,
                                              @RequestParam(required = false) @ApiParam(value ="寤鸿鏍囬") String jybt,
                                              @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page,
@@ -126,20 +127,19 @@
         wq.eq(TjAdvice::getIsZj, isZj);
         if(StringUtil.isNotBlank(jynr)) wq.like(TjAdvice::getAdvice,jynr);
         if(StringUtil.isNotBlank(jybt)) wq.like(TjAdvice::getTitle,jybt);
-        wq.and(i -> i.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex));
+//        wq.and(i -> i.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex));
         Page<TjAdvice> kjbqPage = tjAdviceService.page(page1, wq);
         return AjaxResult.success(kjbqPage);
     }
 
 
-    @GetMapping("/getCyTjAdviceKjbqBySex")
+/*    @GetMapping("/getCyTjAdviceKjbqBySex")
     @ApiOperation(value = "鏍规嵁褰撳墠鐧诲綍浜篿d鑾峰彇甯哥敤寤鸿")
-    public AjaxResult getCyTjAdviceKjbqBySex(@RequestParam String sex, @RequestParam @ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉") Long userId,
+    public AjaxResult getCyTjAdviceKjbqBySex(@RequestParam(required = false) String sex, @RequestParam @ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉") Long userId,
                                              @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page,
                                              @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize) {
         LambdaQueryWrapper<TjAdvice> wq = new LambdaQueryWrapper<>();
         Page<TjAdvice> page1 = new Page<>(page, pageSize);
-//        wq.eq(TjAdvice::getAdSex,sex).or().eq(TjAdvice::getAdSex,"2");
         if (null != userId) {
             LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>();
             wq0.eq(TjUserAdvice::getUserId, userId);
@@ -147,10 +147,44 @@
             if (null != list && !list.isEmpty()) {
                 List<Long> longs = list.stream().map(TjUserAdvice::getAdviceId).collect(Collectors.toList());
                 wq.in(TjAdvice::getId,longs);
-//                wq.last("and (ad_sex=1 OR ad_sex=2)");
                 Page<TjAdvice> kjbqPage = tjAdviceService.page(page1,wq);
                 return AjaxResult.success(kjbqPage);
             }
+        }
+        return AjaxResult.success("璇ョ敤鎴锋殏鏃舵病鏈夊父鐢ㄥ缓璁�!");
+    }*/
+
+
+    @GetMapping("/getCyTjAdviceKjbqBySex")
+    @ApiOperation(value = "鏍规嵁褰撳墠鐧诲綍浜篿d鑾峰彇甯哥敤寤鸿")
+    public AjaxResult getCyTjAdviceKjbqBySex( @RequestParam @ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉") Long userId,
+                                             @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page,
+                                             @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
+                                             @RequestParam(required = false) String nr) {
+        LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>();
+        if(!SecurityUtils.isAdmin(userId))
+            wq0.eq(TjUserAdvice::getUserId, userId);
+        List<TjUserAdvice> list = userAdviceService.list(wq0);
+        List<TjAdvice> kjbqPage = new ArrayList<>();
+        Map<String,Object> map = new HashMap<>();
+        if (null != list && !list.isEmpty()) {
+            for (TjUserAdvice advice : list) {
+                TjAdvice advice1 = tjAdviceService.getById(advice.getAdviceId());
+                if(null != advice1){
+                    advice1.setUserName(userService.getById(advice.getUserId()).getNickName());
+                    kjbqPage.add(advice1);
+                }
+            }
+            List<TjAdvice> adviceList =null;
+            if(StringUtil.isNotBlank( nr)){
+                adviceList = kjbqPage.stream().filter(kjbq -> StringUtil.isNotBlank(kjbq.getTitle()) && kjbq.getTitle().contains(nr))
+                        .skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+            }else {
+                adviceList = kjbqPage.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+            }
+            map.put("total", kjbqPage.size());
+            map.put("records", adviceList);
+            return AjaxResult.success(map);
         }
         return AjaxResult.success("璇ョ敤鎴锋殏鏃舵病鏈夊父鐢ㄥ缓璁�!");
     }
@@ -160,7 +194,7 @@
     @ApiOperation(value = "娣诲姞褰撳墠鐧诲綍浜哄父鐢ㄥ缓璁帴鍙�")
     public AjaxResult addCyTjAdviceByUserId(@RequestParam @ApiParam(value = "鎵�閫夊缓璁富閿甶d鏁扮粍") List<Long> adviceIds) {
         String userId = UserHoder.getLoginUser().getUserId();
-        if (null != adviceIds && adviceIds.size() > 0) {
+        if (null != adviceIds && !adviceIds.isEmpty()) {
             for (Long id : adviceIds) {
                 TjUserAdvice tjUserAdvice = userAdviceService.getTjUserAdviceByUserId(Long.valueOf(userId), id);
                 if (null == tjUserAdvice) {
@@ -174,6 +208,30 @@
         }
         return AjaxResult.success("璇烽�夋嫨鎮ㄨ娣诲姞鐨勫缓璁�!");
     }
+
+
+    @GetMapping("/edaitCyTjAdviceByUserId")
+    @ApiOperation(value = "淇敼褰撳墠鐧诲綍浜哄父鐢ㄥ缓璁帴鍙�")
+    public AjaxResult edaitCyTjAdviceByUserId(@RequestParam @ApiParam(value = "鎵�閫夊缓璁富閿甶d鏁扮粍") List<Long> adviceIds) {
+        String userId = UserHoder.getLoginUser().getUserId();
+        if (null != adviceIds && !adviceIds.isEmpty()) {
+            LambdaQueryWrapper<TjUserAdvice> wq=new LambdaQueryWrapper<>();
+            wq.eq(TjUserAdvice::getUserId,userId);
+            userAdviceService.remove(wq);
+            for (Long id : adviceIds) {
+                TjUserAdvice tjUserAdvice = userAdviceService.getTjUserAdviceByUserId(Long.valueOf(userId), id);
+                if (null == tjUserAdvice) {
+                    TjUserAdvice userAdvice = new TjUserAdvice();
+                    userAdvice.setAdviceId(id);
+                    userAdvice.setUserId(Long.valueOf(userId));
+                    userAdviceService.save(userAdvice);
+                }
+            }
+            return AjaxResult.success("娣诲姞鎴愬姛!");
+        }
+        return AjaxResult.success("璇烽�夋嫨鎮ㄨ娣诲姞鐨勫缓璁�!");
+    }
+
 
 
     @PostMapping("/addCyTjAdvice")
@@ -327,6 +385,7 @@
 //    @PreAuthorize("@ss.hasPermi('advice:advice:edit')")
     @Log(title = "advice", businessType = BusinessType.UPDATE)
     @PutMapping
+    @ApiOperation(value = "淇敼浣撴寤鸿鎺ュ彛")
     public AjaxResult edit(@RequestBody TjAdvice tjAdvice) {
         return AjaxResult.success(tjAdviceService.updateById(tjAdvice));
     }
@@ -340,4 +399,18 @@
     public AjaxResult remove(@PathVariable Long[] ids) {
         return AjaxResult.success(tjAdviceService.deleteTjAdviceByIds(ids));
     }
+
+
+    @DeleteMapping("/delCyremove")
+    @ApiOperation(value = "鍒犻櫎鐢ㄦ埛甯哥敤寤鸿鎺ュ彛")
+    public AjaxResult delCyremove(@RequestParam List<String> ids) {
+        String userId = UserHoder.getLoginUser().getUserId();
+        LambdaQueryWrapper<TjUserAdvice> wq=new LambdaQueryWrapper<>();
+        wq.in(TjUserAdvice::getAdviceId,ids);
+        wq.eq(TjUserAdvice::getUserId,userId);
+        if (userAdviceService.remove(wq)) {
+            return AjaxResult.success();
+        }
+        return AjaxResult.error();
+    }
 }

--
Gitblit v1.8.0