chenbiao 2 éve
szülő
commit
8eeebac80e

+ 11 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpMsgFollowAssociationMapper.java

@@ -0,0 +1,11 @@
+package com.cyksj.mapper.corp;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.CorpMsgFollowAssociation;
+
+/**
+ * @author chan
+ * @date 2024/1/18 14:22
+ */
+public interface CorpMsgFollowAssociationMapper extends BaseMapper<CorpMsgFollowAssociation> {
+}

+ 1 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollow.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @author chan

+ 19 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpMsgFollowAssociation.java

@@ -0,0 +1,19 @@
+package com.cyksj.model.entity;
+
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Data;
+
+/**
+ * @author chan
+ * @date 2024/1/18 14:00
+ */
+@Data
+@SearchBean(tables = " corp_follow cf,corp_msg_follow_association ca ", where = "cf.userid = ca.follow_id")
+public class CorpMsgFollowAssociation extends BaseEntity{
+
+    private String followId;
+
+    private String associationFollowId;
+
+    private String nickname;
+}

+ 45 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/CorpMsgFollowAssociationView.java

@@ -0,0 +1,45 @@
+package com.cyksj.model.manage.views;
+
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Data;
+import org.aspectj.weaver.ast.Or;
+
+import java.util.List;
+
+/**
+ * @author chan
+ * @date 2024/1/18 14:50
+ */
+@Data
+@SearchBean(tables = " corp_follow")
+public class CorpMsgFollowAssociationView {
+
+    private Long wxCorpId;
+
+    /**
+     * 成员UserID
+     */
+    private String userid;
+
+    /**
+     * 成员名称
+     */
+    private String name;
+
+    /**
+     * 头像地址
+     */
+    private String avatar;
+
+    /**
+     * 头像缩略图
+     */
+    private String thumbAvatar;
+
+    /**
+     * 关联关系
+     */
+    @DbIgnore
+    private List<CorpMsgFollowAssociationView> associationList;
+}

+ 81 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/CorpUserMsgView.java

@@ -0,0 +1,81 @@
+package com.cyksj.model.manage.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author chan
+ * @date 2024/1/19 10:43
+ */
+@Data
+@SearchBean(tables = " corp_user c, corp_user_auth cu ,corp_user_follow_relation cr, corp_user_tag t ",
+        where = "cu.corp_user_id = c.id " +
+                "and cu.external_userid = cr.corp_user_id " +
+                "and cr.id = t.relation_id ",
+        groupBy = "c.name, c.avatar, c.type, c.gender, c.unionid, c.user_id, c.state, c.mark_info, c.created_time"
+)
+public class CorpUserMsgView {
+
+    /**
+     * 外部联系人的名称
+     */
+    @DbField("c.name")
+    private String name;
+
+    /**
+     * 外部联系人头像,代开发自建应用需要管理员授权才可以获取,第三方不可获取,上游企业不可获取下游企业客户该字段
+     */
+    @DbField("c.name")
+    private String avatar;
+
+    /**
+     * 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
+     */
+    @DbField("c.type")
+    private Integer type;
+
+    /**
+     * 外部联系人性别 0-未知 1-男性 2-女性。第三方不可获取,上游企业不可获取下游企业客户该字段,返回值为0,表示未定义
+     */
+    @DbField("c.gender")
+    private Integer gender;
+
+    /**
+     * 外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。仅当联系人类型是微信用户,且企业绑定了微信开发者ID有此字段。
+     */
+    @DbField("c.unionid")
+    private String unionid;
+
+    /**
+     * user表 关联用户id
+     */
+    @DbField("c.user_id")
+    private Long userId;
+
+    /**
+     * 添加渠道来源
+     */
+    @DbField("c.state")
+    private String state;
+
+    /**
+     * 客服标记内容
+     */
+    @DbField("c.mark_info")
+    private String markInfo;
+
+    @DbField("c.created_time")
+    private Date createdTime;
+
+
+    /**
+     * 标签组
+     */
+    @DbField("group_concat(t.tag_name)")
+    private List<String> tags;
+}

+ 11 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpMsgFollowAssociationService.java

@@ -0,0 +1,11 @@
+package com.cyksj.service.corp;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cyksj.model.entity.CorpMsgFollowAssociation;
+
+/**
+ * @author chan
+ * @date 2024/1/18 16:16
+ */
+public interface CorpMsgFollowAssociationService extends IService<CorpMsgFollowAssociation> {
+}

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/corp/WxCorpOps.java

@@ -177,4 +177,9 @@ public interface WxCorpOps {
 	 * 删除获客链接
 	 */
 	WxCpLinkAddResp customerAcquisitionDeleteLink(String corpId, WxCpLinkUpd wxCpLinkUpd) throws Exception;
+
+	/**
+	 * 获取会话内容存档开启成员列表
+	 */
+	List<String> getPermitUserList(String corpId, String type) throws Exception;
 }

+ 15 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpMsgFollowAssociationServiceImpl.java

@@ -0,0 +1,15 @@
+package com.cyksj.service.corp.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.mapper.corp.CorpMsgFollowAssociationMapper;
+import com.cyksj.model.entity.CorpMsgFollowAssociation;
+import com.cyksj.service.corp.CorpMsgFollowAssociationService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author chan
+ * @date 2024/1/18 16:18
+ */
+@Service
+public class CorpMsgFollowAssociationServiceImpl extends ServiceImpl<CorpMsgFollowAssociationMapper, CorpMsgFollowAssociation> implements CorpMsgFollowAssociationService {
+}

+ 27 - 1
netflix-service/src/main/java/com/cyksj/service/corp/impl/WxCorpOpsImpl.java

@@ -740,7 +740,7 @@ public class WxCorpOpsImpl implements WxCorpOps {
 
 	@Override
 	public WxCpLinkAddResp customerAcquisitionDeleteLink(String corpId, WxCpLinkUpd wxCpLinkUpd) throws Exception {
-		String url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/delete_link?access_token=" + getAccessToken(corpId);
+		String url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/delete_link?access_token="
 
 		HttpResponse<String> res =
 				J11HttpC.custom()
@@ -759,4 +759,30 @@ public class WxCorpOpsImpl implements WxCorpOps {
 		}
 		return resp;
 	}
+
+	@Override
+	public List<String> getPermitUserList(String corpId, String type) throws Exception {
+		String url = "https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_permit_user_list?access_token=" + getAccessToken(corpId);
+
+		JSONObject params = new JSONObject();
+		if (StringUtils.isNotBlank(type)) {
+			params.putOpt("type",type);
+		}
+		HttpResponse<String> res =
+				J11HttpC.custom()
+						.ofPost()
+						.url(url)
+						.headers(J11HttpC.ReqType.raw_json)
+						.body(HttpRequest.BodyPublishers.ofString(Jsons.toJson(params), IoKit.Charsets.UTF_8.getCharset()))
+						.send(HttpResponse.BodyHandlers.ofString());
+		if (200 != res.statusCode()) {
+			throw BusinessRuntimeException.getInstance("获取会话内容存档开启成员列表: " + res.body());
+		}
+
+		CorpBaseResult resp = Jsons.parseObject(res.body(), CorpBaseResult.class);
+		if (resp.getErrcode() != 0) {
+			throw BusinessRuntimeException.getInstance("获取会话内容存档开启成员列表: " + resp.getErrmsg());
+		}
+		return JSONUtil.parseObj(res.body()).getJSONArray("ids").toList(String.class);
+	}
 }

+ 21 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpMsgContentController.java

@@ -0,0 +1,21 @@
+package com.cyksj.web.controller.manage.corp;
+
+import com.ejlchina.searcher.BeanSearcher;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author chan
+ * @date 2024/1/18 17:46
+ */
+@Slf4j
+@RestController
+@RequestMapping("/manage/msg/content")
+@RequiredArgsConstructor
+public class CorpMsgContentController {
+
+    private final BeanSearcher beanSearcher;
+
+}

+ 97 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpMsgFollowController.java

@@ -0,0 +1,97 @@
+package com.cyksj.web.controller.manage.corp;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.config.corp.YHLXWxCorpConfig;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.model.entity.CorpMsgFollowAssociation;
+import com.cyksj.model.manage.views.CorpMsgFollowAssociationView;
+import com.cyksj.service.corp.CorpFollowService;
+import com.cyksj.service.corp.CorpMsgFollowAssociationService;
+import com.cyksj.service.corp.WxCorpOps;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.param.Operator;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author chan
+ * @date 2024/1/18 12:14
+ */
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/manage/msg/follow")
+public class CorpMsgFollowController {
+
+    private final CorpFollowService corpFollowService;
+
+    private final CorpMsgFollowAssociationService corpMsgFollowAssociationService;
+
+    private final BeanSearcher beanSearcher;
+
+    private final HttpServletRequest request;
+
+    private final WxCorpOps wxCorpOps;
+
+    private final YHLXWxCorpConfig corpConfig;
+
+    /**
+     *  会话存档开启成员列表
+     * @author chan
+     * @date 2024-01-18 17:27
+     */
+    @GetMapping
+    public Result<SearchResult<CorpMsgFollowAssociationView>> getPermitUserList() throws Exception {
+        List<String> res = wxCorpOps.getPermitUserList(corpConfig.getCorpId(), null);
+        SearchResult<CorpMsgFollowAssociationView> search = beanSearcher.search(CorpMsgFollowAssociationView.class, MapUtils.flatBuilder(request.getParameterMap()).field(CorpMsgFollowAssociationView::getUserid, res).op(Operator.InList).build());
+        search.getDataList().forEach((data)->{
+            List<CorpMsgFollowAssociation> corpMsgFollowAssociations = beanSearcher.searchAll(CorpMsgFollowAssociation.class, MapUtils.builder().field(CorpMsgFollowAssociation::getFollowId, data.getUserid()).build());
+            List<String> followIds = corpMsgFollowAssociations.stream().map(CorpMsgFollowAssociation::getAssociationFollowId).collect(Collectors.toList());
+            List<CorpMsgFollowAssociationView> corpMsgFollowAssociationViews = beanSearcher.searchAll(CorpMsgFollowAssociationView.class, MapUtils.builder().field(CorpMsgFollowAssociationView::getUserid, followIds).op(Operator.InList).build());
+            data.setAssociationList(corpMsgFollowAssociationViews);
+        });
+        return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+    }
+
+    /**
+     *
+     * @return
+     */
+    @GetMapping("/all")
+    public Result<List<CorpMsgFollowAssociationView>> getAll() throws Exception {
+        List<String> res = wxCorpOps.getPermitUserList(corpConfig.getCorpId(), null);
+        List<CorpMsgFollowAssociationView> search = beanSearcher.searchAll(CorpMsgFollowAssociationView.class, MapUtils.flatBuilder(request.getParameterMap()).field(CorpMsgFollowAssociationView::getUserid, res).op(Operator.InList).build());
+
+        return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+    }
+
+    /**
+     * 新增会话存档关系
+     * @author chan
+     * @date 2024-01-18 17:26
+     */
+    @PostMapping
+    public Result<String> addAssociation(@RequestBody CorpMsgFollowAssociation corpMsgFollowAssociation){
+        corpMsgFollowAssociationService.save(corpMsgFollowAssociation);
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
+
+    /**
+     * 删除会话存档关系
+     * @author chan
+     * @date 2024-01-18 17:26
+     */
+    @DeleteMapping
+    public Result<String> delAssociation(@RequestBody CorpMsgFollowAssociation corpMsgFollowAssociation){
+        corpMsgFollowAssociationService.remove(Wrappers.lambdaQuery(CorpMsgFollowAssociation.class).eq(CorpMsgFollowAssociation::getAssociationFollowId,corpMsgFollowAssociation.getAssociationFollowId()).eq(CorpMsgFollowAssociation::getFollowId,corpMsgFollowAssociation.getFollowId()));
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
+}

+ 31 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpUserController.java

@@ -0,0 +1,31 @@
+package com.cyksj.web.controller.manage.corp;
+
+import com.cyksj.dto.Result;
+import com.cyksj.model.manage.views.CorpUserMsgView;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author chan
+ * @date 2024/1/19 10:48
+ */
+@Slf4j
+@RestController
+@RequestMapping("/manage/corp/user")
+@RequiredArgsConstructor
+public class CorpUserController {
+
+    private final BeanSearcher beanSearcher;
+
+    @GetMapping
+    public Result<SearchResult<CorpUserMsgView>> get(){
+
+    }
+
+
+}