| package com.ruoyi.other.controller; | 
|   | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.ruoyi.account.api.dto.TagListQueryDto; | 
| import com.ruoyi.account.api.dto.UnitListQueryDto; | 
| import com.ruoyi.common.core.domain.R; | 
| import com.ruoyi.other.api.domain.TCompany; | 
| import com.ruoyi.other.api.domain.TUserTag; | 
| import com.ruoyi.other.mapper.TUserTagMapper; | 
| import com.ruoyi.other.service.TUserTagService; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.annotation.Resource; | 
| import java.time.LocalDateTime; | 
| import java.util.List; | 
| import java.util.Map; | 
| import java.util.stream.Collectors; | 
|   | 
| /** | 
|  * <p> | 
|  *  前端控制器 | 
|  * </p> | 
|  * | 
|  * @author 无关风月 | 
|  * @since 2024-08-06 | 
|  */ | 
| @RestController | 
| @RequestMapping("/t-user-tag") | 
| public class TUserTagController { | 
|     @Resource | 
|     private TUserTagService tUserTagService; | 
|   | 
|     //标签分页 | 
|     @PostMapping(value = "/page") | 
|     public R<Page<TUserTag>> page(@RequestBody TagListQueryDto tagListQueryDto) { | 
|         Page<TUserTag> page = tUserTagService.lambdaQuery() | 
|                 .orderByDesc(TUserTag::getCreateTime) | 
|                 .like(tagListQueryDto.getTagName()!=null&& tagListQueryDto.getTagName()!="", TUserTag::getName, tagListQueryDto.getTagName()) | 
|                 .page(Page.of(tagListQueryDto.getPageCurr(), tagListQueryDto.getPageSize())); | 
|         return R.ok(page); | 
|   | 
|     } | 
|     //标签新增修改 | 
|     @PostMapping(value = "/addorUpdateTag") | 
|     public R addorUpdateTag(@RequestBody TUserTag tUserTag) { | 
|         tUserTag.setCreateTime(LocalDateTime.now()); | 
|         tUserTagService.saveOrUpdate(tUserTag); | 
|         return R.ok(); | 
|     } | 
|     //标签删除 | 
|     @PostMapping(value = "/delete") | 
|     public R delete(@RequestParam("id") Integer id) { | 
|         tUserTagService.removeById(id); | 
|         return R.ok(); | 
|     } | 
|   | 
|     //获取标签map | 
|     @PostMapping(value = "/getTagMap") | 
|     public R<Map<Integer, String>> getTagMap(@RequestBody List<Integer> ids) { | 
|   | 
|         List<TUserTag> list = tUserTagService.lambdaQuery().in(!ids.isEmpty(), TUserTag::getId, ids).list(); | 
|         Map<Integer, String> idNameMap = list.stream() | 
|                 .collect(Collectors.toMap( | 
|                         TUserTag::getId, | 
|                         TUserTag::getName | 
|                 )); | 
|         return R.ok(idNameMap); | 
|     } | 
|   | 
|     @PostMapping(value = "/getById") | 
|     public R<TUserTag> getById(@RequestParam("id") Integer id) { | 
|   | 
|         return R.ok(tUserTagService.getById(id)); | 
|     } | 
|      | 
|      | 
|     /** | 
|      * 获取所有有效数据 | 
|      * @return | 
|      */ | 
|     @PostMapping(value = "/getAllUserTag") | 
|     public R<List<TUserTag>> getAllUserTag(){ | 
|         List<TUserTag> list = tUserTagService.list(new LambdaQueryWrapper<TUserTag>().eq(TUserTag::getDelFlag, 0)); | 
|         return R.ok(list); | 
|     } | 
|   | 
| } |