Browse Source

fix 会话标签多选筛选

zoujiajian 2 years ago
parent
commit
1564c03fcb

+ 13 - 4
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpMsgAuditController.java

@@ -1,8 +1,10 @@
 package com.cyksj.web.controller.manage.corp;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.common.util.Jsons;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.entity.QyMsgContent;
@@ -19,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
@@ -49,11 +52,11 @@ public class CorpMsgAuditController {
     /**
      * 会话存档用户列表
      * @param textKey 关键词搜索
-     * @param tagId 标签筛选
+     * @param tagIds 标签筛选
      * @return
      */
     @GetMapping
-    public Result<SearchResult<CorpMsgAuditUserView>> get(String textKey, String tagId, Integer intention) {
+    public Result<SearchResult<CorpMsgAuditUserView>> get(String textKey, @RequestParam(value = "tagIds", required = false) List<String> tagIds, Integer intention) throws Exception {
         Set<String> userIds = new HashSet<>();
         if(StringUtils.isNotBlank(textKey)){
             List<QyMsgContent> text = corpQyMsgContentService.list(Wrappers.lambdaQuery(QyMsgContent.class).select(QyMsgContent::getFrom, QyMsgContent::getExternalUserid,QyMsgContent::getTolist).like(QyMsgContent::getText, textKey).eq(QyMsgContent::getRoomid,"").eq(QyMsgContent::getMsgtype, "text"));
@@ -63,8 +66,14 @@ public class CorpMsgAuditController {
         if (userIds.size() > 0) {
             builder.field(CorpMsgAuditUserView::getExternalUserid,userIds).op(InList.class);
         }
-        if(StringUtils.isNotBlank(tagId)){
-            builder.put("tag", String.format( "and cr.id = t.relation_id and t.tag_id = '%s'", tagId));
+        if(CollUtil.isNotEmpty(tagIds)){
+            StringBuilder tagStr = new StringBuilder();
+            if (tagIds.size() == 1) {
+                tagStr.append("=").append("'").append(tagIds.get(0)).append("'");
+            } else {
+                tagStr.append("in").append(Jsons.toJson(tagIds).replaceAll("\\[", "(").replaceAll("]", ")"));
+            }
+            builder.put("tag", String.format( "and cr.id = t.relation_id and t.tag_id %s", tagStr));
             builder.put("tagTable", ",corp_user_tag t");
         }
         if (intention != null) {