Browse Source

企业黑名单

yaodaoseng 2 weeks ago
parent
commit
fa1961c5c1

+ 185 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/qywx/RoomBlacklistResponse.java

@@ -0,0 +1,185 @@
+package com.tzld.piaoquan.risk.control.model.qywx;
+
+import java.util.List;
+
+/**
+ * 企业微信群黑名单查询响应实体类
+ * 
+ * @author 风控系统开发团队
+ * @since 1.0.0
+ */
+public class RoomBlacklistResponse {
+    
+    /**
+     * 错误码,0表示成功
+     */
+    private int errcode;
+    
+    /**
+     * 错误信息
+     */
+    private String errmsg;
+    
+    /**
+     * 响应数据
+     */
+    private Data data;
+    
+    public int getErrcode() {
+        return errcode;
+    }
+    
+    public void setErrcode(int errcode) {
+        this.errcode = errcode;
+    }
+    
+    public String getErrmsg() {
+        return errmsg;
+    }
+    
+    public void setErrmsg(String errmsg) {
+        this.errmsg = errmsg;
+    }
+    
+    public Data getData() {
+        return data;
+    }
+    
+    public void setData(Data data) {
+        this.data = data;
+    }
+    
+    /**
+     * 响应数据内容
+     */
+    public static class Data {
+        
+        /**
+         * 分页缓冲区
+         */
+        private String pageBuff;
+        
+        /**
+         *
+         */
+        private boolean is_reset;
+        
+        /**
+         * 是否查询完毕
+         */
+        private boolean is_end;
+        
+        /**
+         * 总数量
+         */
+        private int sum;
+        
+        /**
+         * 黑名单用户列表
+         */
+        private List<BlacklistItem> list;
+        
+        public String getPageBuff() {
+            return pageBuff;
+        }
+        
+        public void setPageBuff(String pageBuff) {
+            this.pageBuff = pageBuff;
+        }
+        
+        public boolean isIs_reset() {
+            return is_reset;
+        }
+        
+        public void setIs_reset(boolean is_reset) {
+            this.is_reset = is_reset;
+        }
+        
+        public boolean isIs_end() {
+            return is_end;
+        }
+        
+        public void setIs_end(boolean is_end) {
+            this.is_end = is_end;
+        }
+        
+        public int getSum() {
+            return sum;
+        }
+        
+        public void setSum(int sum) {
+            this.sum = sum;
+        }
+        
+        public List<BlacklistItem> getList() {
+            return list;
+        }
+        
+        public void setList(List<BlacklistItem> list) {
+            this.list = list;
+        }
+    }
+    
+    /**
+     * 黑名单用户项
+     */
+    public static class BlacklistItem {
+        
+        /**
+         * 黑名单用户VID
+         */
+        private Long blacklist_vid;
+        
+        /**
+         * 拉黑时间(时间戳10位)
+         */
+        private Long create_time;
+        
+        /**
+         * 谁拉黑的
+         */
+        private Long share_vid;
+        
+        public Long getBlacklist_vid() {
+            return blacklist_vid;
+        }
+        
+        public void setBlacklist_vid(Long blacklist_vid) {
+            this.blacklist_vid = blacklist_vid;
+        }
+        
+        public Long getCreate_time() {
+            return create_time;
+        }
+        
+        public void setCreate_time(Long create_time) {
+            this.create_time = create_time;
+        }
+        
+        public Long getShare_vid() {
+            return share_vid;
+        }
+        
+        public void setShare_vid(Long share_vid) {
+            this.share_vid = share_vid;
+        }
+        
+        @Override
+        public String toString() {
+            return "BlacklistItem{" +
+                    "blacklist_vid=" + blacklist_vid +
+                    ", create_time=" + create_time +
+                    ", share_vid=" + share_vid +
+                    '}';
+        }
+    }
+    
+    @Override
+    public String toString() {
+        return "RoomBlacklistResponse{" +
+                "errcode=" + errcode +
+                ", errmsg='" + errmsg + '\'' +
+                ", data=" + data +
+                '}';
+    }
+}

+ 70 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/impl/RiskUserOperateService.java

@@ -284,4 +284,74 @@ public class RiskUserOperateService {
             log.info("forceCloseRoomSwitch, roomId: {}, autoRemoveUserSwitch set to 0", roomId);
         }
     }
+
+    /**
+     * 查询群黑名单
+     *
+     * 调用企业微信API获取指定群的黑名单用户列表
+     *
+     * @param uuid 企业微信用户UUID
+     * @return 黑名单查询响应结果
+     */
+    public RoomBlacklistResponse getRoomBlacklist(String uuid) {
+        if (uuid == null || uuid.trim().isEmpty()) {
+            LOGGER.error("getRoomBlacklist called with null or empty uuid");
+            return createErrorResponse(-1, "UUID不能为空");
+        }
+
+        try {
+            // 构建请求参数
+            Map<String, Object> requestBody = new HashMap<>();
+            requestBody.put("uuid", uuid);
+            requestBody.put("limit", 1000);
+
+            // 构建API URL
+            String url = qywxConfig.getDomain() + qywxConfig.getPath("get-room-black-list");
+
+            LOGGER.info("Calling getRoomBlacklist API, uuid: {}, limit: {}", uuid, 1000);
+
+            // 调用API
+            Optional<String> response = httpPoolClientDefault.postJson(url, JSON.toJSONString(requestBody.toString()));
+
+            if (response.isPresent()) {
+                String responseBody = response.get();
+                LOGGER.info("getRoomBlacklist API response: {}", responseBody);
+
+                // 解析响应
+                RoomBlacklistResponse result = JSON.parseObject(responseBody, RoomBlacklistResponse.class);
+
+                if (result != null && result.getErrcode() == 0) {
+                    LOGGER.info("Successfully retrieved room blacklist, uuid: {}, count: {}",
+                            uuid, result.getData() != null ? result.getData().getSum() : 0);
+                } else {
+                    LOGGER.warn("getRoomBlacklist API returned error, uuid: {}, errcode: {}, errmsg: {}",
+                            uuid,  result != null ? result.getErrcode() : -1,
+                            result != null ? result.getErrmsg() : "解析失败");
+                }
+
+                return result;
+            } else {
+                LOGGER.error("getRoomBlacklist API call failed, no response received, uuid: {}", uuid);
+                return createErrorResponse(-1, "API调用失败,未收到响应");
+            }
+
+        } catch (Exception e) {
+            LOGGER.error("Exception occurred while calling getRoomBlacklist API, uuid: {}", uuid, e);
+            return createErrorResponse(-1, "API调用异常: " + e.getMessage());
+        }
+    }
+
+    /**
+     * 创建错误响应
+     *
+     * @param errcode 错误码
+     * @param errmsg 错误信息
+     * @return 错误响应对象
+     */
+    private RoomBlacklistResponse createErrorResponse(int errcode, String errmsg) {
+        RoomBlacklistResponse response = new RoomBlacklistResponse();
+        response.setErrcode(errcode);
+        response.setErrmsg(errmsg);
+        return response;
+    }
 }

+ 4 - 1
risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/CorpBlacklistController.java

@@ -6,7 +6,10 @@ import com.tzld.piaoquan.risk.control.service.CorpBlacklistService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 

+ 1 - 0
risk-control-server/src/main/resources/application.yml

@@ -42,5 +42,6 @@ qywx:
     get-chatList: /wxwork/GetChatroomMembers
     get-roomMembers: /wxwork/GetRoomUserList
     kick-external: /wxwork/addOrSubRoomBlackList
+    get-room-black-list: /wxwork/getRoomBlackList
 getUserList:
   url: "https://api.piaoquantv.com/ad/platform/wechat/group/groupUserDetailData"  # 测试获取用户列表地址