|
@@ -1,25 +1,23 @@
|
|
|
package com.fs.company.service.impl;
|
|
package com.fs.company.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
-import com.fs.company.domain.Company;
|
|
|
|
|
-import com.fs.company.domain.CompanyUser;
|
|
|
|
|
-import com.fs.company.domain.CompanyWxAccount;
|
|
|
|
|
-import com.fs.company.domain.CompanyWxClient;
|
|
|
|
|
|
|
+import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.CompanyWxAccountMapper;
|
|
import com.fs.company.mapper.CompanyWxAccountMapper;
|
|
|
import com.fs.company.mapper.CompanyWxClientMapper;
|
|
import com.fs.company.mapper.CompanyWxClientMapper;
|
|
|
-import com.fs.company.service.ICompanyService;
|
|
|
|
|
-import com.fs.company.service.ICompanyUserService;
|
|
|
|
|
-import com.fs.company.service.ICompanyWxAccountService;
|
|
|
|
|
|
|
+import com.fs.company.service.*;
|
|
|
import com.fs.wxcid.domain.CidIpadServerUser;
|
|
import com.fs.wxcid.domain.CidIpadServerUser;
|
|
|
import com.fs.wxcid.domain.WxContact;
|
|
import com.fs.wxcid.domain.WxContact;
|
|
|
|
|
+import com.fs.wxcid.dto.friend.ContactItem;
|
|
|
import com.fs.wxcid.dto.friend.ContactListResponse;
|
|
import com.fs.wxcid.dto.friend.ContactListResponse;
|
|
|
import com.fs.wxcid.dto.friend.GetContactDetailsResponseData;
|
|
import com.fs.wxcid.dto.friend.GetContactDetailsResponseData;
|
|
|
import com.fs.wxcid.dto.login.LoginStatusResponseData;
|
|
import com.fs.wxcid.dto.login.LoginStatusResponseData;
|
|
|
|
|
+import com.fs.wxcid.dto.message.ChatroomMember;
|
|
|
import com.fs.wxcid.dto.message.UserNameWrapper;
|
|
import com.fs.wxcid.dto.message.UserNameWrapper;
|
|
|
import com.fs.wxcid.dto.user.UserInfo;
|
|
import com.fs.wxcid.dto.user.UserInfo;
|
|
|
import com.fs.wxcid.dto.user.UserInfoExt;
|
|
import com.fs.wxcid.dto.user.UserInfoExt;
|
|
@@ -28,10 +26,10 @@ import com.fs.wxcid.mapper.wx.ModContactDbMapper;
|
|
|
import com.fs.wxcid.service.*;
|
|
import com.fs.wxcid.service.*;
|
|
|
import com.fs.wxcid.service.impl.LoginServiceImpl;
|
|
import com.fs.wxcid.service.impl.LoginServiceImpl;
|
|
|
import com.fs.wxcid.service.impl.UserServiceImpl;
|
|
import com.fs.wxcid.service.impl.UserServiceImpl;
|
|
|
-import com.fs.wxcid.vo.VerifyUserValidTicketListVo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -39,7 +37,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 企微账号Service业务层处理
|
|
* 企微账号Service业务层处理
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @author fs
|
|
* @author fs
|
|
|
* @date 2024-12-09
|
|
* @date 2024-12-09
|
|
|
*/
|
|
*/
|
|
@@ -49,6 +47,12 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
private final static String FRIEND_KEY = "cid:wx:friend-list:";
|
|
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", "qqmail");
|
|
private final static List<String> REMOVE_FRIEND_STR_ARRAY = Arrays.asList("weixin", "fmessage", "medianote", "gh_3dfda90e39d6", "qqmail");
|
|
|
private final static String IS_ROOM_KEY = "@chatroom";
|
|
private final static String IS_ROOM_KEY = "@chatroom";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final long SYNC_INTERVAL = 30 * 1000; // 同步间隔时间
|
|
|
|
|
+ private static final int BATCH_SIZE = 100; // 批量插入批次大小
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CompanyWxAccountMapper companyWxAccountMapper;
|
|
private CompanyWxAccountMapper companyWxAccountMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -77,10 +81,16 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
private ModContactDbMapper modContactDbMapper;
|
|
private ModContactDbMapper modContactDbMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IWxContactService wxContactService;
|
|
private IWxContactService wxContactService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IWxRoomService wxRoomService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IWxRoomMembersService wxRoomMembersService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询企微账号
|
|
* 查询企微账号
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param id 企微账号ID
|
|
* @param id 企微账号ID
|
|
|
* @return 企微账号
|
|
* @return 企微账号
|
|
|
*/
|
|
*/
|
|
@@ -92,7 +102,7 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询企微账号列表
|
|
* 查询企微账号列表
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param companyWxAccount 企微账号
|
|
* @param companyWxAccount 企微账号
|
|
|
* @return 企微账号
|
|
* @return 企微账号
|
|
|
*/
|
|
*/
|
|
@@ -110,7 +120,7 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 新增企微账号
|
|
* 新增企微账号
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param companyWxAccount 企微账号
|
|
* @param companyWxAccount 企微账号
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
@@ -123,7 +133,7 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 修改企微账号
|
|
* 修改企微账号
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param companyWxAccount 企微账号
|
|
* @param companyWxAccount 企微账号
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
@@ -135,7 +145,7 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 批量删除企微账号
|
|
* 批量删除企微账号
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param ids 需要删除的企微账号ID
|
|
* @param ids 需要删除的企微账号ID
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
@@ -147,7 +157,7 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 删除企微账号信息
|
|
* 删除企微账号信息
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param id 企微账号ID
|
|
* @param id 企微账号ID
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
@@ -274,17 +284,228 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void syncWx(Long accountId) {
|
|
public void syncWx(Long accountId) {
|
|
|
|
|
+ // 1. 参数校验
|
|
|
|
|
+ if (accountId == null) {
|
|
|
|
|
+ log.error("同步微信信息失败:accountId不能为空");
|
|
|
|
|
+ throw new IllegalArgumentException("accountId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 获取账号信息并更新同步时间
|
|
|
CompanyWxAccount account = getById(accountId);
|
|
CompanyWxAccount account = getById(accountId);
|
|
|
|
|
+ if (account == null) {
|
|
|
|
|
+ log.error("同步微信信息失败:个微账号不存在,accountId={}", accountId);
|
|
|
|
|
+ throw new RuntimeException("个微账号不存在,accountId=" + accountId);
|
|
|
|
|
+ }
|
|
|
account.setSyncFriendTime(LocalDateTime.now());
|
|
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);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 3. 清理Redis缓存
|
|
|
|
|
+ String key = FRIEND_KEY + accountId;
|
|
|
|
|
+ friendListRedis.deleteObject(key);
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 获取好友列表并过滤
|
|
|
|
|
+ ContactListResponse response = friendService.getContactListNotKey(accountId);
|
|
|
|
|
+ List<String> friendList = getFilteredFriendList(response);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(friendList)) {
|
|
|
|
|
+ log.info("账号暂无需要同步的微信好友/群聊,accountId={}", accountId);
|
|
|
|
|
+ updateById(account);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 缓存好友列表到Redis
|
|
|
|
|
+ friendListRedis.setCacheObject(key, friendList);
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 同步联系人信息
|
|
|
|
|
+ syncContactDetails(accountId, account, friendList);
|
|
|
|
|
+
|
|
|
|
|
+ // 7. 更新账号信息
|
|
|
|
|
+ updateById(account);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("微信信息同步完成,accountId={},同步联系人数量={}", accountId, friendList.size());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("同步微信信息异常,accountId={}", accountId, e);
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取过滤后的好友列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<String> getFilteredFriendList(ContactListResponse response) {
|
|
|
|
|
+ if (response == null || response.getContactList() == null ||
|
|
|
|
|
+ CollectionUtils.isEmpty(response.getContactList().getContactUsernameList())) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 过滤掉无效的好友标识
|
|
|
|
|
+ return response.getContactList().getContactUsernameList()
|
|
|
|
|
+ .stream().filter(e -> !REMOVE_FRIEND_STR_ARRAY.contains(e)).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步联系人详情信息
|
|
|
|
|
+ */
|
|
|
|
|
+ private void syncContactDetails(Long accountId, CompanyWxAccount account, List<String> friendList) {
|
|
|
|
|
+ List<WxContact> wxContacts = new ArrayList<>();
|
|
|
|
|
+ List<WxRoom> wxRooms = new ArrayList<>();
|
|
|
|
|
+ List<WxRoomMembers> wxRoomMembersList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (String username : friendList) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取联系人详情
|
|
|
|
|
+ GetContactDetailsResponseData contactDetails = friendService.getContactDetailsList(accountId, Collections.singletonList(username));
|
|
|
|
|
+ if (contactDetails == null || CollectionUtils.isEmpty(contactDetails.getContactList())) {
|
|
|
|
|
+ log.warn("联系人详情为空,username={},accountId={}", username, accountId);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据类型处理不同的联系人
|
|
|
|
|
+ List<ContactItem> contactList = contactDetails.getContactList();
|
|
|
|
|
+ if (username.endsWith("@chatroom")) {
|
|
|
|
|
+ // 处理群聊信息
|
|
|
|
|
+ convertToWxRoom(contactList, wxRooms);
|
|
|
|
|
+ // 处理群成员信息
|
|
|
|
|
+ convertToWxRoomMembers(contactList, wxRoomMembersList);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 处理个人好友信息
|
|
|
|
|
+ convertToWxContact(contactList, accountId, account, wxContacts);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 控制同步频率,避免接口限流
|
|
|
|
|
+ Thread.sleep(SYNC_INTERVAL);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ log.error("同步联系人信息被中断,username={},accountId={}", username, accountId, e);
|
|
|
|
|
+ Thread.currentThread().interrupt(); // 恢复中断状态
|
|
|
|
|
+ break; // 中断循环,避免无效执行
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("同步单个联系人信息失败,username={},accountId={}", username, accountId, e);
|
|
|
|
|
+ // 继续处理下一个联系人,不中断整体同步
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 批量插入数据(设置批次大小,避免一次性插入过多数据)
|
|
|
|
|
+ batchSaveData(wxContacts, wxRooms, wxRoomMembersList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量保存数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void batchSaveData(List<WxContact> wxContacts, List<WxRoom> wxRooms, List<WxRoomMembers> wxRoomMembersList) {
|
|
|
|
|
+ // 保存群聊信息
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(wxRooms)) {
|
|
|
|
|
+ wxRoomService.saveBatch(wxRooms, BATCH_SIZE);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 保存个人好友信息
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(wxContacts)) {
|
|
|
|
|
+ wxContactService.saveBatch(wxContacts, BATCH_SIZE);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 保存群成员信息
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(wxRoomMembersList)) {
|
|
|
|
|
+ wxRoomMembersService.saveBatch(wxRoomMembersList, BATCH_SIZE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转换为WxRoom对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void convertToWxRoom(List<ContactItem> contactList, List<WxRoom> wxRooms) {
|
|
|
|
|
+ ContactItem contactItem = contactList.get(0);
|
|
|
|
|
+ if (contactItem == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ WxRoom wxRoom = new WxRoom();
|
|
|
|
|
+ wxRoom.setRoomId(getStringValue(contactItem.getUserName()));
|
|
|
|
|
+ wxRoom.setRoomName(getStringValue(contactItem.getNickName()));
|
|
|
|
|
+ wxRoom.setRoomOwnerId(contactItem.getChatRoomOwner());
|
|
|
|
|
+ wxRoom.setChatroomMaxCount(parseInt(contactItem.getChatroomMaxCount()));
|
|
|
|
|
+ wxRoom.setMemberCount(parseInt(contactItem.getNewChatroomData() != null ? contactItem.getNewChatroomData().getMemberCount() : null));
|
|
|
|
|
+ wxRoom.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxRoom.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxRooms.add(wxRoom);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转换为WxRoomMembers对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void convertToWxRoomMembers(List<ContactItem> contactList, List<WxRoomMembers> wxRoomMembersList) {
|
|
|
|
|
+ ContactItem contactItem = contactList.get(0);
|
|
|
|
|
+ if (contactItem == null || contactItem.getNewChatroomData() == null ||
|
|
|
|
|
+ CollectionUtils.isEmpty(contactItem.getNewChatroomData().getChatroomMemberList())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String roomId = getStringValue(contactItem.getUserName());
|
|
|
|
|
+ String roomName = getStringValue(contactItem.getNickName());
|
|
|
|
|
+ String roomOwnerId = contactItem.getChatRoomOwner();
|
|
|
|
|
+
|
|
|
|
|
+ for (ChatroomMember chatroomMember : contactItem.getNewChatroomData().getChatroomMemberList()) {
|
|
|
|
|
+ if (chatroomMember == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ WxRoomMembers wxRoomMembers = new WxRoomMembers();
|
|
|
|
|
+ wxRoomMembers.setRoomId(roomId);
|
|
|
|
|
+ wxRoomMembers.setRoomName(roomName);
|
|
|
|
|
+ wxRoomMembers.setRoomOwnerId(roomOwnerId);
|
|
|
|
|
+ wxRoomMembers.setRoomMemberId(chatroomMember.getUserName());
|
|
|
|
|
+ wxRoomMembers.setRoomMemberName(chatroomMember.getNickName());
|
|
|
|
|
+ wxRoomMembers.setChatroomMemberFlag(chatroomMember.getChatroomMemberFlag());
|
|
|
|
|
+ wxRoomMembers.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxRoomMembers.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxRoomMembersList.add(wxRoomMembers);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转换为WxContact对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void convertToWxContact(List<ContactItem> contactList, Long accountId,
|
|
|
|
|
+ CompanyWxAccount account, List<WxContact> wxContacts) {
|
|
|
|
|
+ ContactItem contactItem = contactList.get(0);
|
|
|
|
|
+ if (contactItem == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ WxContact wxContact = new WxContact();
|
|
|
|
|
+ wxContact.setUserName(getStringValue(contactItem.getUserName()));
|
|
|
|
|
+ wxContact.setNickName(getStringValue(contactItem.getNickName()));
|
|
|
|
|
+ wxContact.setQuanPin(getStringValue(contactItem.getQuanPin()));
|
|
|
|
|
+ wxContact.setSex(contactItem.getSex());
|
|
|
|
|
+ wxContact.setAlias(contactItem.getAlias());
|
|
|
|
|
+ wxContact.setHeadImgUrl(contactItem.getBigHeadImgUrl());
|
|
|
|
|
+ wxContact.setEncryptUserName(contactItem.getEncryptUserName());
|
|
|
|
|
+ wxContact.setProvince(contactItem.getProvince());
|
|
|
|
|
+ wxContact.setCity(contactItem.getCity());
|
|
|
|
|
+ wxContact.setAccountId(accountId);
|
|
|
|
|
+ wxContact.setCompanyId(account.getCompanyId());
|
|
|
|
|
+ wxContact.setCompanyUserId(account.getCompanyUserId());
|
|
|
|
|
+ wxContact.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxContact.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
+ wxContacts.add(wxContact);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全获取字符串值(避免空指针)
|
|
|
|
|
+ */
|
|
|
|
|
+ private String getStringValue(UserNameWrapper obj) {
|
|
|
|
|
+ return obj != null && obj.getStr() != null ? obj.getStr() : "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全转换为整数
|
|
|
|
|
+ */
|
|
|
|
|
+ private Integer parseInt(Object value) {
|
|
|
|
|
+ if (value == null) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Integer.valueOf(value.toString());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ log.warn("转换整数失败,value={}", value);
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void isCheckContact(String formUser, Long accountId) {
|
|
public void isCheckContact(String formUser, Long accountId) {
|
|
|
GetContactDetailsResponseData details = friendService.getContactDetailsList(accountId, Collections.singletonList(formUser));
|
|
GetContactDetailsResponseData details = friendService.getContactDetailsList(accountId, Collections.singletonList(formUser));
|