修正接口字段遗漏
This commit is contained in:
parent
651f1528f6
commit
049fba65a8
@ -66,6 +66,7 @@ public class CacheConfig {
|
||||
|
||||
configMap.put(COURSE, new LocalMapConfig(10000, 300));
|
||||
configMap.put(GROUP, new LocalMapConfig(10000, 300));
|
||||
configMap.put(WX_USER, new LocalMapConfig(10000, 3600));
|
||||
return configMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,6 +305,12 @@ public class CacheKey {
|
||||
public static final String CUSTOMER_SALE = "customer_sale|";
|
||||
}
|
||||
|
||||
public static final String WX_USER = "wx_user";
|
||||
|
||||
public static final class WxUserKey {
|
||||
public static final String USER = "user|";
|
||||
}
|
||||
|
||||
public static final String SCREEN = "screen";
|
||||
|
||||
public static final class ScreenKey {
|
||||
|
||||
@ -28,6 +28,7 @@ import com.syzb.rbac.entity.Dept;
|
||||
import com.syzb.rbac.entity.UserDept;
|
||||
import com.syzb.rbac.service.DeptService;
|
||||
import com.syzb.rbac.service.UserService;
|
||||
import com.syzb.rbac.service.WxUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -63,6 +64,9 @@ public class CommentBlackService {
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
|
||||
@Resource
|
||||
private WxUserService wxUserService;
|
||||
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -198,6 +202,7 @@ public class CommentBlackService {
|
||||
commentBlackVO.setUserOrgName(dept.getName());
|
||||
}
|
||||
}
|
||||
commentBlackVO.setUserHeadPic(wxUserService.getHeadPic(commentBlackVO.getPhone()));
|
||||
}
|
||||
return new Pager<>(voList, page.getTotal());
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ public class CommentBlackVO extends CommonPhoneVO {
|
||||
@ApiModelProperty("用户姓名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户头像")
|
||||
private String userHeadPic;
|
||||
|
||||
@ApiModelProperty("产品id")
|
||||
private Integer productId;
|
||||
|
||||
@ -102,6 +105,14 @@ public class CommentBlackVO extends CommonPhoneVO {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserHeadPic() {
|
||||
return userHeadPic;
|
||||
}
|
||||
|
||||
public void setUserHeadPic(String userHeadPic) {
|
||||
this.userHeadPic = userHeadPic;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ import com.syzb.group.vo.message.GroupMessageReadVO;
|
||||
import com.syzb.group.vo.message.GroupMessageVO;
|
||||
import com.syzb.rbac.entity.WxUser;
|
||||
import com.syzb.rbac.mapper.WxUserMapper;
|
||||
import com.syzb.rbac.service.WxUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -94,6 +95,9 @@ public class AdminGroupMessageService {
|
||||
@Resource
|
||||
private WxUserMapper wxUserMapper;
|
||||
|
||||
@Resource
|
||||
private WxUserService wxUserService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public OnlyIdVO sendAdvisorMessage(SendGroupMessageAdminQuery query, BackendUserVO backendUser) {
|
||||
GroupInfo group = groupInfoMapper.selectById(query.getGroupId());
|
||||
@ -184,11 +188,37 @@ public class AdminGroupMessageService {
|
||||
groupCacheService.queryMessageReadCount(vo);
|
||||
}
|
||||
}
|
||||
if (GroupMessageUserType.CUSTOMER.value.equals(vo.getUserType())) {
|
||||
vo.setUserHeadPicUrl(wxUserService.getHeadPic(vo.getUserId()));
|
||||
}
|
||||
if (StrUtil.isNotEmpty(vo.getPrivateUserId())) {
|
||||
vo.setPrivateUserHeadPicUrl(wxUserService.getHeadPic(vo.getPrivateUserId()));
|
||||
}
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
return new AppPager<>(voList, hasNext);
|
||||
}
|
||||
|
||||
// private Map<String, WxUser> getWxUserMap(List<GroupMessage> list) {
|
||||
// Set<String> userIds = new HashSet<>();
|
||||
// for (GroupMessage message : list) {
|
||||
// if (GroupMessageUserType.CUSTOMER.value.equals(message.getUserType())) {
|
||||
// userIds.add(message.getUserId());
|
||||
// }
|
||||
// if (message.getPrivateUserId() != null) {
|
||||
// userIds.add(message.getPrivateUserId());
|
||||
// }
|
||||
// }
|
||||
// Map<String, WxUser> queryUserIdSet = new HashMap<>(userIds.size());
|
||||
// if (CollUtil.isNotEmpty(userIds)) {
|
||||
// LambdaQueryWrapper<WxUser> userWrapper = Wrappers.<WxUser>lambdaQuery()
|
||||
// .in(WxUser::getId, userIds);
|
||||
// List<WxUser> wxUserList = wxUserMapper.selectList(userWrapper);
|
||||
// wxUserList.forEach(user -> queryUserIdSet.put(user.getId(), user));
|
||||
// }
|
||||
// return queryUserIdSet;
|
||||
// }
|
||||
|
||||
public AppPager<GroupMessageVO> getPrivateChatList(PagePrivateChatQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getGroupId();
|
||||
Integer size = query.getSize();
|
||||
@ -196,7 +226,7 @@ public class AdminGroupMessageService {
|
||||
String nickName = query.getNickName();
|
||||
Integer lastId = query.getLastId();
|
||||
Set<String> queryUserIdSet = null;
|
||||
if (StrUtil.isNotEmpty(userId) && StrUtil.isNotEmpty(nickName)) {
|
||||
if (StrUtil.isNotEmpty(userId) || StrUtil.isNotEmpty(nickName)) {
|
||||
LambdaQueryWrapper<WxUser> userWrapper = Wrappers.<WxUser>lambdaQuery()
|
||||
.select(WxUser::getId)
|
||||
.eq(StrUtil.isNotEmpty(userId), WxUser::getId, userId)
|
||||
@ -213,7 +243,6 @@ public class AdminGroupMessageService {
|
||||
.lt(lastId != null, "id", lastId)
|
||||
.orderByDesc("id")
|
||||
.last("limit " + (size + 1));
|
||||
System.out.println(wrapper.getCustomSqlSegment());
|
||||
List<GroupMessage> list = groupMessageMapper.selectPrivateChatList(groupId, wrapper);
|
||||
boolean hasNext = list.size() > size;
|
||||
if (hasNext) {
|
||||
@ -236,7 +265,7 @@ public class AdminGroupMessageService {
|
||||
return AppPager.emptyPager();
|
||||
}
|
||||
Set<String> queryUserIdSet = null;
|
||||
if (StrUtil.isNotEmpty(userId) && StrUtil.isNotEmpty(nickName)) {
|
||||
if (StrUtil.isNotEmpty(userId) || StrUtil.isNotEmpty(nickName)) {
|
||||
LambdaQueryWrapper<WxUser> userWrapper = Wrappers.<WxUser>lambdaQuery()
|
||||
.select(WxUser::getId)
|
||||
.eq(StrUtil.isNotEmpty(userId), WxUser::getId, userId)
|
||||
@ -267,6 +296,7 @@ public class AdminGroupMessageService {
|
||||
List<WxUser> wxUserList = wxUserMapper.selectList(Wrappers.<WxUser>lambdaQuery()
|
||||
.in(WxUser::getId, userIdSet));
|
||||
Map<String, WxUser> wxUserMap = wxUserList.stream().collect(Collectors.toMap(WxUser::getId, Function.identity()));
|
||||
Set<String> blackUserIds = commentBlackService.getBlackUserIds(groupId, ProductType.GROUP.value);
|
||||
List<GroupCustomerVO> list = moduleUserList.stream().map(moduleUser -> {
|
||||
GroupCustomerVO vo = new GroupCustomerVO(moduleUser);
|
||||
WxUser wxUser = wxUserMap.get(moduleUser.getUserId());
|
||||
@ -274,6 +304,7 @@ public class AdminGroupMessageService {
|
||||
vo.setNickName(wxUser.getNickName());
|
||||
vo.setHeadPicUrl(wxUser.getImgUrl());
|
||||
}
|
||||
vo.setCommentBlackStatus(blackUserIds.contains(moduleUser.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
return new AppPager<>(list, hasNext);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.syzb.group.service.common;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
@ -18,6 +19,8 @@ import com.syzb.group.mapper.GroupMessageMapper;
|
||||
import com.syzb.group.mapper.GroupMessageReadMapper;
|
||||
import com.syzb.group.vo.message.GroupMessageReadVO;
|
||||
import com.syzb.group.vo.message.GroupMessageVO;
|
||||
import com.syzb.rbac.service.WxUserService;
|
||||
import com.syzb.rbac.vo.WxUserVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -39,6 +42,9 @@ public class GroupCacheService {
|
||||
@Resource
|
||||
private GroupMessageMapper groupMessageMapper;
|
||||
|
||||
@Resource
|
||||
private WxUserService wxUserService;
|
||||
|
||||
@Resource
|
||||
private IMap<String, Object> groupCache;
|
||||
|
||||
@ -134,7 +140,7 @@ public class GroupCacheService {
|
||||
}
|
||||
|
||||
public GroupMessageVO getMessage(Integer messageId, Map<Integer, AdvisorBasicVO> advisorMap) {
|
||||
return cacheService.get(groupCache,
|
||||
GroupMessageVO vo = cacheService.get(groupCache,
|
||||
CacheKey.GroupKey.GROUP_MESSAGE_DETAIL + messageId, () -> {
|
||||
GroupMessage message = groupMessageMapper.selectById(messageId);
|
||||
if (message == null) {
|
||||
@ -142,6 +148,16 @@ public class GroupCacheService {
|
||||
}
|
||||
return getMessage(message, advisorMap);
|
||||
});
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
if (GroupMessageUserType.CUSTOMER.value.equals(vo.getUserType())) {
|
||||
vo.setUserHeadPicUrl(wxUserService.getHeadPic(vo.getUserId()));
|
||||
}
|
||||
if (StrUtil.isNotEmpty(vo.getPrivateUserId())) {
|
||||
vo.setPrivateUserHeadPicUrl(wxUserService.getHeadPic(vo.getPrivateUserId()));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
public GroupMessageVO getMessage(GroupMessage message, Map<Integer, AdvisorBasicVO> advisorMap) {
|
||||
|
||||
@ -31,7 +31,7 @@ public class GroupCustomerVO {
|
||||
@ApiModelProperty("客户状态 1:在期 2:已到期 3:即将到期 4:新学员")
|
||||
private Integer customerStatus;
|
||||
|
||||
@ApiModelProperty("禁言状态 0生效中 1已解除 2自然过期")
|
||||
@ApiModelProperty("禁言状态 1:已禁言 2:未禁言")
|
||||
private Integer commentBlackStatus;
|
||||
|
||||
@ApiModelProperty("最近一次访问时间")
|
||||
|
||||
@ -30,6 +30,9 @@ public class GroupMessageVO implements Serializable {
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户头像")
|
||||
private String userHeadPicUrl;
|
||||
|
||||
@ApiModelProperty("接受用户ID")
|
||||
private String toUserId;
|
||||
|
||||
@ -42,6 +45,9 @@ public class GroupMessageVO implements Serializable {
|
||||
@ApiModelProperty("私聊用户名称")
|
||||
private String privateUserName;
|
||||
|
||||
@ApiModelProperty("私聊用户头像")
|
||||
private String privateUserHeadPicUrl;
|
||||
|
||||
@ApiModelProperty("消息内容")
|
||||
private String content;
|
||||
|
||||
@ -172,6 +178,14 @@ public class GroupMessageVO implements Serializable {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserHeadPicUrl() {
|
||||
return userHeadPicUrl;
|
||||
}
|
||||
|
||||
public void setUserHeadPicUrl(String userHeadPicUrl) {
|
||||
this.userHeadPicUrl = userHeadPicUrl;
|
||||
}
|
||||
|
||||
public String getToUserId() {
|
||||
return toUserId;
|
||||
}
|
||||
@ -204,6 +218,14 @@ public class GroupMessageVO implements Serializable {
|
||||
this.privateUserName = privateUserName;
|
||||
}
|
||||
|
||||
public String getPrivateUserHeadPicUrl() {
|
||||
return privateUserHeadPicUrl;
|
||||
}
|
||||
|
||||
public void setPrivateUserHeadPicUrl(String privateUserHeadPicUrl) {
|
||||
this.privateUserHeadPicUrl = privateUserHeadPicUrl;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
41
src/main/java/com/syzb/rbac/service/WxUserService.java
Normal file
41
src/main/java/com/syzb/rbac/service/WxUserService.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.syzb.rbac.service;
|
||||
|
||||
import com.syzb.common.config.cache.CacheKey;
|
||||
import com.syzb.common.service.CacheService;
|
||||
import com.syzb.rbac.entity.WxUser;
|
||||
import com.syzb.rbac.mapper.WxUserMapper;
|
||||
import com.syzb.rbac.vo.WxUserVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class WxUserService {
|
||||
|
||||
@Resource
|
||||
private WxUserMapper wxUserMapper;
|
||||
|
||||
@Resource
|
||||
private CacheService cacheService;
|
||||
|
||||
public WxUserVO get(String userId) {
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
return cacheService.get(CacheKey.WX_USER, CacheKey.WxUserKey.USER + userId, () -> {
|
||||
WxUser user = wxUserMapper.selectById(userId);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return new WxUserVO(user);
|
||||
});
|
||||
}
|
||||
|
||||
public String getHeadPic(String userId) {
|
||||
WxUserVO user = get(userId);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return user.getImgUrl();
|
||||
}
|
||||
}
|
||||
47
src/main/java/com/syzb/rbac/vo/WxUserVO.java
Normal file
47
src/main/java/com/syzb/rbac/vo/WxUserVO.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.syzb.rbac.vo;
|
||||
|
||||
import com.syzb.rbac.entity.WxUser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WxUserVO implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String imgUrl;
|
||||
|
||||
public WxUserVO() {
|
||||
}
|
||||
|
||||
public WxUserVO(WxUser user) {
|
||||
this.id = user.getId();
|
||||
this.nickName = user.getNickName();
|
||||
this.imgUrl = user.getImgUrl();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getImgUrl() {
|
||||
return imgUrl;
|
||||
}
|
||||
|
||||
public void setImgUrl(String imgUrl) {
|
||||
this.imgUrl = imgUrl;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user