feat:聊天会员限制
This commit is contained in:
1 parent
41aea55ec3
commit
dad88ffcc6
8 files changed
+148
No files matched your search
+9
@@ -1,5 +1,6 @@
|
||||
package com.bx.implatform.controller.third;
|
||||
|
||||
import com.bx.implatform.dto.MessageTotalDto;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageCountDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageInfoDTO;
|
||||
@@ -7,6 +8,7 @@ import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageSendDTO;
|
||||
import com.bx.implatform.result.Result;
|
||||
import com.bx.implatform.result.ResultUtils;
|
||||
import com.bx.implatform.service.third.ThirdPrivateMsgService;
|
||||
import com.bx.implatform.vo.MessageTotalVo;
|
||||
import com.bx.implatform.vo.PrivateMessageVO;
|
||||
import com.bx.implatform.vo.third.ThirdTableVO;
|
||||
import com.bx.implatform.vo.third.privatemsg.ThirdPrivateMessageVO;
|
||||
@@ -59,4 +61,11 @@ public class ThirdPrivateMsgController {
|
||||
return ResultUtils.success(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/total")
|
||||
@Operation(summary = "私聊消息发送消息的统计", description = "私聊消息发送消息的统计")
|
||||
public Result<List<MessageTotalVo>> total(@Valid @RequestBody MessageTotalDto dto) {
|
||||
List<MessageTotalVo> vo = thirdPrivateMsgService.total(dto);
|
||||
return ResultUtils.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.bx.implatform.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class MessageTotalDto {
|
||||
|
||||
/**
|
||||
* 发送人id
|
||||
*/
|
||||
private Long sendId;
|
||||
|
||||
/**
|
||||
* 接收人id
|
||||
*/
|
||||
private Long receiveId;
|
||||
|
||||
/**
|
||||
* 发送时间范围
|
||||
*/
|
||||
private LocalDateTime[] timeRange;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.bx.implatform.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bx.implatform.dto.MessageTotalDto;
|
||||
import com.bx.implatform.entity.PrivateMessage;
|
||||
import com.bx.implatform.vo.MessageTotalVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@@ -18,4 +20,6 @@ public interface PrivateMessageMapper extends BaseMapper<PrivateMessage> {
|
||||
)
|
||||
List<Map<String, Object>> getDailyMessageCount(@Param("days") Integer days);
|
||||
|
||||
List<MessageTotalVo> total(@Param("dto") MessageTotalDto dto);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.bx.implatform.service.third;
|
||||
|
||||
import com.bx.implatform.dto.MessageTotalDto;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageCountDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageInfoDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageSendDTO;
|
||||
import com.bx.implatform.vo.MessageTotalVo;
|
||||
import com.bx.implatform.vo.PrivateMessageVO;
|
||||
import com.bx.implatform.vo.third.ThirdTableVO;
|
||||
import com.bx.implatform.vo.third.privatemsg.ThirdPrivateMessageVO;
|
||||
@@ -33,4 +35,9 @@ public interface ThirdPrivateMsgService {
|
||||
* 按天统计私聊消息量
|
||||
*/
|
||||
List<Map<String, Object>> getDailyMessageCount(@Valid ThirdPrivateMessageCountDTO dto);
|
||||
|
||||
/**
|
||||
* 私聊消息发送消息的统计
|
||||
*/
|
||||
List<MessageTotalVo> total(@Valid MessageTotalDto dto);
|
||||
}
|
||||
+40
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bx.imclient.IMClient;
|
||||
import com.bx.imcommon.model.IMPrivateMessage;
|
||||
import com.bx.imcommon.model.IMUserInfo;
|
||||
import com.bx.implatform.dto.MessageTotalDto;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageCountDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageDTO;
|
||||
import com.bx.implatform.dto.third.privatemsg.ThirdPrivateMessageInfoDTO;
|
||||
@@ -29,6 +30,7 @@ import com.bx.implatform.session.SessionContext;
|
||||
import com.bx.implatform.session.UserSession;
|
||||
import com.bx.implatform.util.BeanUtils;
|
||||
import com.bx.implatform.util.SensitiveFilterUtil;
|
||||
import com.bx.implatform.vo.MessageTotalVo;
|
||||
import com.bx.implatform.vo.PrivateMessageVO;
|
||||
import com.bx.implatform.vo.third.ThirdTableVO;
|
||||
import com.bx.implatform.vo.third.privatemsg.ThirdPrivateMessageVO;
|
||||
@@ -47,6 +49,7 @@ import java.util.*;
|
||||
public class ThirdPrivateMsgServiceImpl extends ServiceImpl<PrivateMessageMapper, PrivateMessage> implements ThirdPrivateMsgService {
|
||||
|
||||
private final UserMapper userMapper;
|
||||
private final PrivateMessageMapper privateMessageMapper;
|
||||
|
||||
private final IMClient imClient;
|
||||
private final FriendService friendService;
|
||||
@@ -151,6 +154,43 @@ public class ThirdPrivateMsgServiceImpl extends ServiceImpl<PrivateMessageMapper
|
||||
return baseMapper.getDailyMessageCount(days);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私聊消息发送消息的统计
|
||||
*/
|
||||
@Override
|
||||
public List<MessageTotalVo> total(MessageTotalDto dto) {
|
||||
List<MessageTotalVo> totalList = privateMessageMapper.total(dto);
|
||||
disposeTotalList(totalList);
|
||||
return totalList;
|
||||
}
|
||||
|
||||
private void disposeTotalList(List<MessageTotalVo> totalList) {
|
||||
if (ObjectUtil.isEmpty(totalList)) return;
|
||||
List<Long> sendIdList = totalList.stream().map(MessageTotalVo::getSendId).distinct().filter(ObjectUtil::isNotEmpty).toList();
|
||||
List<Long> receiveIdList = totalList.stream().map(MessageTotalVo::getReceiveId).distinct().filter(ObjectUtil::isNotEmpty).toList();
|
||||
HashSet<Long> userIdList = new HashSet<>();
|
||||
userIdList.addAll(sendIdList);
|
||||
userIdList.addAll(receiveIdList);
|
||||
if (ObjectUtil.isNotEmpty(userIdList)) {
|
||||
List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
|
||||
.in(User::getId, userIdList.stream().toList())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(users)) {
|
||||
Map<Long, User> map = IterUtil.toMap(users, User::getId);
|
||||
for (MessageTotalVo total : totalList) {
|
||||
User sendUser = map.get(total.getSendId());
|
||||
if (ObjectUtil.isNotEmpty(sendUser)) {
|
||||
total.setSendName(sendUser.getNickName());
|
||||
}
|
||||
User receiveUser = map.get(total.getReceiveId());
|
||||
if (ObjectUtil.isNotEmpty(receiveUser)) {
|
||||
total.setReceiveName(receiveUser.getNickName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<PrivateMessage> buildQueryWrapper(ThirdPrivateMessageDTO bo) {
|
||||
List<Long> sendIds = new ArrayList<>();
|
||||
List<Long> recvIds = new ArrayList<>();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.bx.implatform.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MessageTotalVo {
|
||||
|
||||
/**
|
||||
* 发送者id
|
||||
*/
|
||||
private Long sendId;
|
||||
|
||||
/**
|
||||
* 发送名
|
||||
*/
|
||||
private String sendName;
|
||||
|
||||
/**
|
||||
* 接受者id
|
||||
*/
|
||||
private Long receiveId;
|
||||
|
||||
/**
|
||||
* 接收者名称
|
||||
*/
|
||||
private String receiveName;
|
||||
|
||||
/**
|
||||
* 消息总数
|
||||
*/
|
||||
private Long messageTotal;
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ mybatis-plus:
|
||||
map-underscore-to-camel-case: true #开启自动驼峰命名规则
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
jwt:
|
||||
accessToken:
|
||||
expireIn: 1800 #半个小时
|
||||
@@ -31,3 +32,4 @@ jwt:
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bx.implatform.mapper.PrivateMessageMapper">
|
||||
|
||||
<sql id="whereA">
|
||||
<if test="dto.sendId != null">
|
||||
and a.send_id = #{dto.sendId}
|
||||
</if>
|
||||
<if test="dto.recvId != null">
|
||||
and a.recv_id = #{dto.recvId}
|
||||
</if>
|
||||
<if test="dto.timeRange != null and dto.timeRange.length == 2">
|
||||
and a.send_time between #{dto.timeRange[0]} and #{dto.timeRange[1]}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="total" resultType="com.bx.implatform.vo.MessageTotalVo">
|
||||
select a.send_id as sendId, a.recv_id as receiveId, count(0) as messageTotal
|
||||
from im_private_message a
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
group by a.send_id, a.recv_id
|
||||
order by a.send_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user