完善接口
This commit is contained in:
parent
fd58f0a874
commit
4e4c52d063
@ -355,6 +355,7 @@ public class CacheKey {
|
||||
public static final String GROUP_MESSAGE_DETAIL = "group_message_detail|";
|
||||
public static final String USER_TOTAL_ONLINE = "user_total_online|";
|
||||
public static final String TEMP_READ_LIST = "temp_read_list";
|
||||
public static final String GROUP_MESSAGE_DATE_ID_MAP = "group_message_date_id_map|";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
26
src/main/java/com/upchina/common/vo/DateIdVO.java
Normal file
26
src/main/java/com/upchina/common/vo/DateIdVO.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.upchina.common.vo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class DateIdVO {
|
||||
|
||||
private LocalDate date;
|
||||
|
||||
private Integer id;
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
package com.upchina.group.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.upchina.common.vo.DateIdVO;
|
||||
import com.upchina.group.entity.GroupMessage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@ -18,12 +21,12 @@ import java.util.List;
|
||||
*/
|
||||
public interface GroupMessageMapper extends BaseMapper<GroupMessage> {
|
||||
|
||||
@Select("SELECT id\n" +
|
||||
"FROM (\n" +
|
||||
" SELECT id, ROW_NUMBER() OVER (PARTITION BY private_user_id ORDER BY id DESC) as rn\n" +
|
||||
" FROM group_message\n" +
|
||||
" WHERE group_id = #{groupId} AND interactive_type = 2 and private_user_id is not null\n" +
|
||||
") t\n" +
|
||||
@Select("SELECT id \n" +
|
||||
"FROM ( \n" +
|
||||
" SELECT id, ROW_NUMBER() OVER (PARTITION BY private_user_id ORDER BY id DESC) as rn \n" +
|
||||
" FROM group_message \n" +
|
||||
" WHERE group_id = #{groupId} AND interactive_type = 2 and private_user_id is not null \n" +
|
||||
") t \n" +
|
||||
"WHERE rn = 1")
|
||||
List<GroupMessage> selectPrivateChatList(@Param("groupId") Integer groupId);
|
||||
|
||||
@ -38,4 +41,10 @@ public interface GroupMessageMapper extends BaseMapper<GroupMessage> {
|
||||
"WHERE user_type = 2 AND create_time >= #{startTime} AND create_time < #{endTime} \n" +
|
||||
"GROUP BY group_id, interactive_type")
|
||||
List<GroupMessage> collectMessageMember(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT DATE(create_time) AS date, MAX(id) AS id \n" +
|
||||
"FROM group_message \n" +
|
||||
"${ew.customSqlSegment} \n" +
|
||||
"GROUP BY DATE(create_time) \n")
|
||||
List<DateIdVO> selectDateIdList(@Param(Constants.WRAPPER) Wrapper<GroupMessage> wrapper);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ListGroupMessageAppQuery {
|
||||
|
||||
@ -24,6 +25,9 @@ public class ListGroupMessageAppQuery {
|
||||
@ApiModelProperty("每页大小")
|
||||
private Integer size = 20;
|
||||
|
||||
@ApiModelProperty("日期 yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
|
||||
public Integer getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
@ -55,4 +59,12 @@ public class ListGroupMessageAppQuery {
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@ -69,6 +70,7 @@ public class AppGroupMessageService {
|
||||
Integer lastId = query.getLastId();
|
||||
Integer type = query.getType();
|
||||
Integer size = query.getSize();
|
||||
LocalDate date = query.getDate();
|
||||
GroupVO groupVO = groupInfoService.getForApp(new OnlyIdQuery(groupId), null);
|
||||
if (groupVO == null) {
|
||||
throw new BizException(ResponseStatus.ID_NOT_EXIST_ERROR, "交易圈不存在");
|
||||
@ -83,6 +85,18 @@ public class AppGroupMessageService {
|
||||
if (lastId != null && lastId != 0) {
|
||||
sortedSet = sortedSet.tailSet(lastId, false);
|
||||
}
|
||||
if (LocalDate.now().equals(date)) {
|
||||
date = null;
|
||||
}
|
||||
if (date != null) {
|
||||
TreeMap<LocalDate, Integer> dateIdMap = groupCacheService.getDateIdMap(groupId, userId, msgType);
|
||||
LocalDate floorDate = dateIdMap.floorKey(date);
|
||||
if (floorDate == null) {
|
||||
return AppPager.emptyPager();
|
||||
}
|
||||
Integer maxId = dateIdMap.get(floorDate);
|
||||
sortedSet = sortedSet.tailSet(maxId, true);
|
||||
}
|
||||
List<GroupMessageVO> list = new ArrayList<>(size);
|
||||
Iterator<Integer> it = sortedSet.iterator();
|
||||
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
|
||||
|
||||
@ -9,6 +9,7 @@ import com.upchina.common.config.cache.CacheKey;
|
||||
import com.upchina.common.constant.IsOrNot;
|
||||
import com.upchina.common.entity.OnlineUser;
|
||||
import com.upchina.common.service.CacheService;
|
||||
import com.upchina.common.vo.DateIdVO;
|
||||
import com.upchina.group.constant.GroupInteractiveType;
|
||||
import com.upchina.group.constant.GroupMessageUserType;
|
||||
import com.upchina.group.constant.QueryGroupMessageType;
|
||||
@ -50,16 +51,9 @@ public class GroupCacheService {
|
||||
private IMap<String, Object> groupCache;
|
||||
|
||||
public NavigableSet<Integer> getMessageIdSet(Integer groupId, String userId, QueryGroupMessageType type) {
|
||||
String cacheKey = buildMessageIdSetKey(userId, type);
|
||||
String cacheKey = buildMessageIdSetKey(CacheKey.GroupKey.GROUP_MESSAGE_LIST, userId, type);
|
||||
return cacheService.get(groupCache, cacheKey, () -> {
|
||||
LambdaQueryWrapper<GroupMessage> wrapper = Wrappers.<GroupMessage>lambdaQuery()
|
||||
.select(GroupMessage::getId)
|
||||
.eq(GroupMessage::getGroupId, groupId)
|
||||
.eq(!QueryGroupMessageType.PRIVATE.equals(type), GroupMessage::getInteractiveType, GroupInteractiveType.GROUP.value)
|
||||
.in(QueryGroupMessageType.ADVISOR.equals(type), GroupMessage::getUserType, GroupMessageUserType.ADVISOR.value, GroupMessageUserType.ASSISTANT.value)
|
||||
.eq(QueryGroupMessageType.CUSTOMER.equals(type), GroupMessage::getUserType, GroupMessageUserType.CUSTOMER.value)
|
||||
.eq(QueryGroupMessageType.SELECTED.equals(type), GroupMessage::getIsRecommend, IsOrNot.IS.value)
|
||||
.eq(QueryGroupMessageType.PRIVATE.equals(type), GroupMessage::getPrivateUserId, userId);
|
||||
LambdaQueryWrapper<GroupMessage> wrapper = buildWrapper(groupId, userId, type);
|
||||
List<Object> objList = groupMessageMapper.selectObjs(wrapper);
|
||||
NavigableSet<Integer> set = new TreeSet<>(Comparator.reverseOrder());
|
||||
objList.stream().map(obj -> (Integer) obj).forEach(set::add);
|
||||
@ -67,6 +61,28 @@ public class GroupCacheService {
|
||||
});
|
||||
}
|
||||
|
||||
public TreeMap<LocalDate, Integer> getDateIdMap(Integer groupId, String userId, QueryGroupMessageType type) {
|
||||
String cacheKey = buildMessageIdSetKey(CacheKey.GroupKey.GROUP_MESSAGE_DATE_ID_MAP, userId, type);
|
||||
return cacheService.get(groupCache, cacheKey, () -> {
|
||||
LambdaQueryWrapper<GroupMessage> wrapper = buildWrapper(groupId, userId, type);
|
||||
List<DateIdVO> dateIdList = groupMessageMapper.selectDateIdList(wrapper);
|
||||
TreeMap<LocalDate, Integer> map = new TreeMap<>();
|
||||
dateIdList.stream().forEach(vo -> map.put(vo.getDate(), vo.getId()));
|
||||
return map;
|
||||
});
|
||||
}
|
||||
|
||||
private static LambdaQueryWrapper<GroupMessage> buildWrapper(Integer groupId, String userId, QueryGroupMessageType type) {
|
||||
return Wrappers.<GroupMessage>lambdaQuery()
|
||||
.select(GroupMessage::getId)
|
||||
.eq(GroupMessage::getGroupId, groupId)
|
||||
.eq(!QueryGroupMessageType.PRIVATE.equals(type), GroupMessage::getInteractiveType, GroupInteractiveType.GROUP.value)
|
||||
.in(QueryGroupMessageType.ADVISOR.equals(type), GroupMessage::getUserType, GroupMessageUserType.ADVISOR.value, GroupMessageUserType.ASSISTANT.value)
|
||||
.eq(QueryGroupMessageType.CUSTOMER.equals(type), GroupMessage::getUserType, GroupMessageUserType.CUSTOMER.value)
|
||||
.eq(QueryGroupMessageType.SELECTED.equals(type), GroupMessage::getIsRecommend, IsOrNot.IS.value)
|
||||
.eq(QueryGroupMessageType.PRIVATE.equals(type), GroupMessage::getPrivateUserId, userId);
|
||||
}
|
||||
|
||||
public void removeMessage(GroupMessage message) {
|
||||
String privateUserId = message.getPrivateUserId();
|
||||
Integer groupId = message.getGroupId();
|
||||
@ -92,7 +108,7 @@ public class GroupCacheService {
|
||||
private void removeMessage(Integer groupId, String userId, QueryGroupMessageType type, Integer messageId) {
|
||||
NavigableSet<Integer> set = getMessageIdSet(groupId, userId, type);
|
||||
set.remove(messageId);
|
||||
String cacheKey = buildMessageIdSetKey(userId, type);
|
||||
String cacheKey = buildMessageIdSetKey(CacheKey.GroupKey.GROUP_MESSAGE_LIST, userId, type);
|
||||
groupCache.put(cacheKey, set);
|
||||
}
|
||||
|
||||
@ -121,7 +137,7 @@ public class GroupCacheService {
|
||||
private void addMessage(Integer groupId, String userId, QueryGroupMessageType type, Integer messageId) {
|
||||
NavigableSet<Integer> set = getMessageIdSet(groupId, userId, type);
|
||||
set.add(messageId);
|
||||
String cacheKey = buildMessageIdSetKey(userId, type);
|
||||
String cacheKey = buildMessageIdSetKey(CacheKey.GroupKey.GROUP_MESSAGE_LIST, userId, type);
|
||||
groupCache.put(cacheKey, set);
|
||||
}
|
||||
|
||||
@ -155,8 +171,8 @@ public class GroupCacheService {
|
||||
});
|
||||
}
|
||||
|
||||
private static String buildMessageIdSetKey(String userId, QueryGroupMessageType type) {
|
||||
String cacheKey = CacheKey.GroupKey.GROUP_MESSAGE_LIST + type.value;
|
||||
private static String buildMessageIdSetKey(String prefix, String userId, QueryGroupMessageType type) {
|
||||
String cacheKey = prefix + type.value;
|
||||
if (QueryGroupMessageType.PRIVATE.equals(type)) {
|
||||
cacheKey += "|" + userId;
|
||||
}
|
||||
@ -176,4 +192,5 @@ public class GroupCacheService {
|
||||
vo.setReadCount(groupMessageReadMapper.selectCount(wrapper).intValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -63,7 +63,7 @@ public interface VideoLiveUserMapper extends EasyBaseMapper<VideoLiveUser> {
|
||||
"${ew.customSqlSegment}")
|
||||
<E extends IPage<VideoStatisticUserDetailVO>> E selectVideoUserDetail(Page<?> page, @Param(Constants.WRAPPER) Wrapper<VideoLiveUser> wrapper);
|
||||
|
||||
@Select("SELECT sr.sale_user_id, u.name as sale_user_name, u.staff_no, u.dept_id,\n" +
|
||||
@Select("SELECT sr.sale_user_id, ud.name as sale_user_name, ul.staff_no, ud.dept_id,\n" +
|
||||
"ifnull(sr.count, 0) AS subscribe_user_count, \n" +
|
||||
"ifnull(sc.count, 0) AS browse_pro_people_count, \n" +
|
||||
"ifnull(op.amount, 0) AS sub_amount, \n" +
|
||||
@ -97,8 +97,10 @@ public interface VideoLiveUserMapper extends EasyBaseMapper<VideoLiveUser> {
|
||||
"WHERE s.video_id = #{videoId} AND s.sale_user_id IS NOT NULL AND o.product_type = 3 AND o.pay_status = 2 \n" +
|
||||
"GROUP BY s.sale_user_id) oup \n" +
|
||||
"ON sr.sale_user_id = oup.sale_user_id \n" +
|
||||
"JOIN user u \n" +
|
||||
"ON sr.sale_user_id = u.id \n" +
|
||||
"JOIN user_dept ud \n" +
|
||||
"ON sr.sale_user_id = ud.user_id \n" +
|
||||
"JOIN user_login ul \n" +
|
||||
"ON ud.login_id = ul.login_id \n" +
|
||||
"${ew.customSqlSegment}")
|
||||
<E extends IPage<VideoStatisticStaffDetailVO>> E statisticSaleUserByVideo(Page<?> page,
|
||||
@Param("videoId") Integer videoId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user