| | |
| | | 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; |
| | |
| | | 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 = "根据当前登录人id获取常用建议") |
| | | 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); |
| | |
| | | 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 = "根据当前登录人id获取常用建议") |
| | | 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<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 = 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("该用户暂时没有常用建议!"); |
| | | } |
| | |
| | | @ApiOperation(value = "添加当前登录人常用建议接口") |
| | | public AjaxResult addCyTjAdviceByUserId(@RequestParam @ApiParam(value = "所选建议主键id数组") 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) { |
| | |
| | | } |
| | | return AjaxResult.success("请选择您要添加的建议!"); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/edaitCyTjAdviceByUserId") |
| | | @ApiOperation(value = "修改当前登录人常用建议接口") |
| | | public AjaxResult edaitCyTjAdviceByUserId(@RequestParam @ApiParam(value = "所选建议主键id数组") 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") |
| | |
| | | // @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)); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | } |