From 92fec7876dbbc43f1780e66901ef8bfd0fad445b Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期一, 31 三月 2025 14:33:10 +0800
Subject: [PATCH] zjh20250331

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 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 2389090..028923a 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
@@ -117,6 +117,7 @@
     @ApiOperation(value = "鏍规嵁浣撴浜烘�у埆鍜屾槸鍚︿负鎬绘鏌ヨ浣撴寤鸿鎺ュ彛")
     public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam String sex, @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,
                                              @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize) {
         LambdaQueryWrapper<TjAdvice> wq = new LambdaQueryWrapper<>();
@@ -124,7 +125,8 @@
 //        wq.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex);
         wq.eq(TjAdvice::getIsZj, isZj);
         if(StringUtil.isNotBlank(jynr)) wq.like(TjAdvice::getAdvice,jynr);
-        wq.and(i -> i.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex));
+        if(StringUtil.isNotBlank(jybt)) wq.like(TjAdvice::getTitle,jybt);
+//        wq.and(i -> i.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex));
         Page<TjAdvice> kjbqPage = tjAdviceService.page(page1, wq);
         return AjaxResult.success(kjbqPage);
     }
@@ -132,7 +134,7 @@
 
     @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<>();
@@ -142,10 +144,10 @@
             LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>();
             wq0.eq(TjUserAdvice::getUserId, userId);
             List<TjUserAdvice> list = userAdviceService.list(wq0);
-            if (null != list && list.size() > 0) {
+            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)");
+//                wq.last("and (ad_sex=1 OR ad_sex=2)");
                 Page<TjAdvice> kjbqPage = tjAdviceService.page(page1,wq);
                 return AjaxResult.success(kjbqPage);
             }
@@ -158,7 +160,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) {
@@ -172,6 +174,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")
@@ -207,7 +233,7 @@
                            @ApiParam(value = "寤鸿") @RequestParam(required = false) String nr,
                            @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page,
                            @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
-    @RequestParam(value = "deptId")String deptId) {
+                           @RequestParam(required = false)String deptId) {
 //        LambdaQueryWrapper<SysDept> wrapper = new LambdaQueryWrapper<>();
 //        wrapper.eq(SysDept::getParentId, 0);
 //        SysDept sysDept = sysDeptService.getOne(wrapper);
@@ -270,8 +296,8 @@
 //        }
 //        map.put("list", list);
 //        map.put("total", page2.getTotal());
-        List<TjAdvice> tjAdvices = tjAdviceService.selectList(proName, deptId, (page - 1) * pageSize, pageSize);
-        Integer count = tjAdviceService.selectListCount(proName, deptId);
+        List<TjAdvice> tjAdvices = tjAdviceService.selectList(proName, deptId, (page - 1) * pageSize, pageSize,bt,nr);
+        Integer count = tjAdviceService.selectListCount(proName, deptId,bt,nr);
         HashMap<String, Object> hashMap = new HashMap<>();
         hashMap.put("list",tjAdvices);
         hashMap.put("total",count);
@@ -325,6 +351,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));
     }

--
Gitblit v1.8.0