|
@@ -2,7 +2,10 @@ package com.tzld.piaoquan.risk.control.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.tzld.piaoquan.risk.control.config.QywxConfig;
|
|
|
+import com.tzld.piaoquan.risk.control.dao.mapper.WorkWechatRoomInfoMapper;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.UserBase;
|
|
|
+import com.tzld.piaoquan.risk.control.model.po.WorkWechatRoomInfo;
|
|
|
+import com.tzld.piaoquan.risk.control.model.po.WorkWechatRoomInfoExample;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.QwCommonResModel;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.RiskUserInfo;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.RoomListResponse;
|
|
@@ -10,13 +13,13 @@ import com.tzld.piaoquan.risk.control.model.qywx.RoomMemberListInfo;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpClientUtil;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpPoolClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.lang.reflect.Array;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@@ -25,10 +28,10 @@ public class RiskUserOperateService {
|
|
|
@Autowired
|
|
|
private QywxConfig qywxConfig; // 注入配置类
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WorkWechatRoomInfoMapper workWechatRoomInfoMapper;
|
|
|
@Value("${qywx.corpid}")
|
|
|
private long corpid;
|
|
|
- @Autowired
|
|
|
- private QywxUserDataService qwUserService;
|
|
|
private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(10000, 10000, 2000, 5000, 5, 10000);
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(RiskUserHandleService.class);
|
|
|
|
|
@@ -45,7 +48,7 @@ public class RiskUserOperateService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private void kick(UserBase staff, long roomId, long vid) {
|
|
|
+ public void kick(UserBase staff, long roomId, long vid) {
|
|
|
Map<String, Object> requestBody = new HashMap<>();
|
|
|
requestBody.put("uuid", staff.getUuid());
|
|
|
requestBody.put("oprType", 1);
|
|
@@ -100,29 +103,16 @@ public class RiskUserOperateService {
|
|
|
return memberList;
|
|
|
}
|
|
|
|
|
|
- public void findRoomAndClosed(List<RoomListResponse.RoomInfo> filerRooms, String chatId, UserBase staff) {
|
|
|
- if (filerRooms == null || filerRooms.isEmpty()) {
|
|
|
- log.info("findRoomAndClosed, filerRooms is empty for chatId: {}", chatId);
|
|
|
- return;
|
|
|
- }
|
|
|
- String url = qywxConfig.getDomain() + qywxConfig.getPath("chatIdToRoomId");
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("uuid", staff.getUuid());
|
|
|
- requestBody.put("corpid", corpid);
|
|
|
- requestBody.put("chatid", chatId);
|
|
|
- Optional<String> result = httpPoolClientDefault.postJson(url,JSON.toJSONString(requestBody));
|
|
|
- if (!result.isPresent()) {
|
|
|
- log.error("findRoomAndClosed, result is empty for chatId: {}", chatId);
|
|
|
- return;
|
|
|
- } else {
|
|
|
- String roomId = "";
|
|
|
- try {
|
|
|
- roomId = JSON.parseObject(result.get()).getJSONObject("data").getString("room_id");
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("findRoomAndClosed, error parsing response: {}", result.get(), e);
|
|
|
- return;
|
|
|
- }
|
|
|
+ public void forceCloseRoomSwitch(String roomId) {
|
|
|
+ WorkWechatRoomInfoExample example = new WorkWechatRoomInfoExample();
|
|
|
+ example.createCriteria().andRoomIdEqualTo(roomId);
|
|
|
+ List<WorkWechatRoomInfo> workWechatRoomInfos = workWechatRoomInfoMapper.selectByExample(example);
|
|
|
+ if (CollectionUtils.isNotEmpty(workWechatRoomInfos)) {
|
|
|
+ WorkWechatRoomInfo workWechatRoomInfo = workWechatRoomInfos.get(0);
|
|
|
+ workWechatRoomInfo.setAutoRemoveUserSwitch(0);
|
|
|
+ workWechatRoomInfo.setUpdateTime(new Date());
|
|
|
+ workWechatRoomInfoMapper.updateByPrimaryKeySelective(workWechatRoomInfo);
|
|
|
+ log.info("forceCloseRoomSwitch, roomId: {}, autoRemoveUserSwitch set to 0", roomId);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|