|
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.redis.RedisCacheT;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
@@ -13,22 +14,27 @@ import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.company.service.ICompanyWxAccountService;
|
|
|
import com.fs.wxcid.domain.CidIpadServerUser;
|
|
|
+import com.fs.wxcid.dto.friend.ContactListResponse;
|
|
|
import com.fs.wxcid.dto.login.LoginStatusData;
|
|
|
import com.fs.wxcid.dto.login.LoginStatusResponseData;
|
|
|
import com.fs.wxcid.dto.user.UserInfo;
|
|
|
import com.fs.wxcid.dto.user.UserInfoExt;
|
|
|
import com.fs.wxcid.dto.user.UserProfileData;
|
|
|
import com.fs.wxcid.service.AdminLicenseService;
|
|
|
+import com.fs.wxcid.service.FriendService;
|
|
|
import com.fs.wxcid.service.ICidIpadServerService;
|
|
|
import com.fs.wxcid.service.ICidIpadServerUserService;
|
|
|
import com.fs.wxcid.service.impl.LoginServiceImpl;
|
|
|
import com.fs.wxcid.service.impl.UserServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 企微账号Service业务层处理
|
|
|
@@ -36,8 +42,12 @@ import java.util.List;
|
|
|
* @author fs
|
|
|
* @date 2024-12-09
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, CompanyWxAccount> implements ICompanyWxAccountService {
|
|
|
+ private final static String FRIEND_KEY = "cid:wx:friend-list:";
|
|
|
+ private final static List<String> REMOVE_FRIEND_STR_ARRAY = Arrays.asList("weixin", "fmessage", "medianote", "gh_3dfda90e39d6");
|
|
|
+ private final static String IS_ROOM_KEY = "@chatroom";
|
|
|
@Autowired
|
|
|
private CompanyWxAccountMapper companyWxAccountMapper;
|
|
|
@Autowired
|
|
|
@@ -54,6 +64,10 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
private AdminLicenseService adminLicenseService;
|
|
|
@Autowired
|
|
|
private UserServiceImpl userService;
|
|
|
+ @Autowired
|
|
|
+ private FriendService friendService;
|
|
|
+ @Autowired
|
|
|
+ private RedisCacheT<List<String>> friendListRedis;
|
|
|
|
|
|
/**
|
|
|
* 查询企微账号
|
|
|
@@ -249,4 +263,16 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
updateById(account);
|
|
|
loginService.logOut(accountId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncWx(Long accountId) {
|
|
|
+ CompanyWxAccount account = getById(accountId);
|
|
|
+ account.setSyncFriendTime(LocalDateTime.now());
|
|
|
+ String key = FRIEND_KEY + accountId;
|
|
|
+ friendListRedis.deleteObject(key);
|
|
|
+ ContactListResponse response = friendService.getContactListNotKey(accountId);
|
|
|
+ List<String> friendList = response.getContactList().getContactUsernameList().stream().filter(e -> !REMOVE_FRIEND_STR_ARRAY.contains(e)).collect(Collectors.toList());
|
|
|
+ friendListRedis.setCacheObject(key, friendList);
|
|
|
+ updateById(account);
|
|
|
+ }
|
|
|
}
|