From 2eb40036e885988fbf93ebcb98a339b197fb6340 Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期四, 05 六月 2025 17:39:52 +0800 Subject: [PATCH] zjh20250605 --- ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 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 fc41316..753f6d8 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 @@ -126,7 +126,7 @@ 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); } @@ -134,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<>(); @@ -147,7 +147,6 @@ 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); } @@ -160,7 +159,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 +173,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 +350,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