mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-06-15 17:57:07 +00:00
mallchat项目重构
This commit is contained in:
43
mallchat-chat-server/pom.xml
Normal file
43
mallchat-chat-server/pom.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mallchat</artifactId>
|
||||
<groupId>com.abin.mallchat</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mallchat-chat-server</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.abin.mallchat</groupId>
|
||||
<artifactId>mallchat-common-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.abin.mallchat</groupId>
|
||||
<artifactId>mallchat-transaction</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.knuddels</groupId>
|
||||
<artifactId>jtokkit</artifactId>
|
||||
<version>0.6.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.abin.mallchat.common;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
|
||||
/**
|
||||
* @author zhongzb
|
||||
* @date 2021/05/27
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = {"com.abin.mallchat"})
|
||||
@MapperScan({"com.abin.mallchat.common.**.mapper"})
|
||||
@ServletComponentScan
|
||||
public class MallchatCustomApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MallchatCustomApplication.class,args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.abin.mallchat.common.chat.consumer;
|
||||
|
||||
import com.abin.mallchat.common.chat.dao.ContactDao;
|
||||
import com.abin.mallchat.common.chat.dao.MessageDao;
|
||||
import com.abin.mallchat.common.chat.dao.RoomDao;
|
||||
import com.abin.mallchat.common.chat.dao.RoomFriendDao;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Room;
|
||||
import com.abin.mallchat.common.chat.domain.entity.RoomFriend;
|
||||
import com.abin.mallchat.common.chat.domain.enums.RoomTypeEnum;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageResp;
|
||||
import com.abin.mallchat.common.chat.service.ChatService;
|
||||
import com.abin.mallchat.common.chat.service.WeChatMsgOperationService;
|
||||
import com.abin.mallchat.common.chat.service.cache.GroupMemberCache;
|
||||
import com.abin.mallchat.common.chat.service.cache.HotRoomCache;
|
||||
import com.abin.mallchat.common.chat.service.cache.RoomCache;
|
||||
import com.abin.mallchat.common.chatai.service.IChatAIService;
|
||||
import com.abin.mallchat.common.common.constant.MQConstant;
|
||||
import com.abin.mallchat.common.common.domain.dto.MsgSendMessageDTO;
|
||||
import com.abin.mallchat.common.user.service.WebSocketService;
|
||||
import com.abin.mallchat.common.user.service.adapter.WSAdapter;
|
||||
import com.abin.mallchat.common.user.service.cache.UserCache;
|
||||
import com.abin.mallchat.common.user.service.impl.PushService;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description: 发送消息更新房间收信箱,并同步给房间成员信箱
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-08-12
|
||||
*/
|
||||
@RocketMQMessageListener(consumerGroup = MQConstant.SEND_MSG_GROUP, topic = MQConstant.SEND_MSG_TOPIC)
|
||||
@Component
|
||||
public class MsgSendConsumer implements RocketMQListener<MsgSendMessageDTO> {
|
||||
@Autowired
|
||||
private WebSocketService webSocketService;
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
@Autowired
|
||||
private MessageDao messageDao;
|
||||
@Autowired
|
||||
private IChatAIService openAIService;
|
||||
@Autowired
|
||||
WeChatMsgOperationService weChatMsgOperationService;
|
||||
@Autowired
|
||||
private RoomCache roomCache;
|
||||
@Autowired
|
||||
private RoomDao roomDao;
|
||||
@Autowired
|
||||
private GroupMemberCache groupMemberCache;
|
||||
@Autowired
|
||||
private UserCache userCache;
|
||||
@Autowired
|
||||
private RoomFriendDao roomFriendDao;
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
@Autowired
|
||||
private ContactDao contactDao;
|
||||
@Autowired
|
||||
private HotRoomCache hotRoomCache;
|
||||
@Autowired
|
||||
private PushService pushService;
|
||||
|
||||
@Override
|
||||
public void onMessage(MsgSendMessageDTO dto) {
|
||||
Message message = messageDao.getById(dto.getMsgId());
|
||||
Room room = roomCache.get(message.getRoomId());
|
||||
ChatMessageResp msgResp = chatService.getMsgResp(message, null);
|
||||
//所有房间更新房间最新消息
|
||||
roomDao.refreshActiveTime(room.getId(), message.getId(), message.getCreateTime());
|
||||
roomCache.delete(room.getId());
|
||||
if (room.isHotRoom()) {//热门群聊推送所有在线的人
|
||||
//更新热门群聊时间-redis
|
||||
hotRoomCache.refreshActiveTime(room.getId(), message.getCreateTime());
|
||||
//推送所有人
|
||||
pushService.sendPushMsg(WSAdapter.buildMsgSend(msgResp));
|
||||
} else {
|
||||
List<Long> memberUidList = new ArrayList<>();
|
||||
if (Objects.equals(room.getType(), RoomTypeEnum.GROUP.getType())) {//普通群聊推送所有群成员
|
||||
memberUidList = groupMemberCache.getMemberUidList(room.getId());
|
||||
} else if (Objects.equals(room.getType(), RoomTypeEnum.FRIEND.getType())) {//单聊对象
|
||||
//对单人推送
|
||||
RoomFriend roomFriend = roomFriendDao.getByRoomId(room.getId());
|
||||
memberUidList = Arrays.asList(roomFriend.getUid1(), roomFriend.getUid2());
|
||||
}
|
||||
//更新所有群成员的会话时间
|
||||
contactDao.refreshOrCreateActiveTime(room.getId(), memberUidList, message.getId(), message.getCreateTime());
|
||||
//推送房间成员
|
||||
pushService.sendPushMsg(WSAdapter.buildMsgSend(msgResp), memberUidList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.abin.mallchat.common.chat.controller;
|
||||
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.dto.MsgReadInfoDTO;
|
||||
import com.abin.mallchat.common.chat.domain.vo.request.*;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberStatisticResp;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageReadResp;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageResp;
|
||||
import com.abin.mallchat.common.chat.service.ChatService;
|
||||
import com.abin.mallchat.common.common.annotation.FrequencyControl;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.utils.RequestHolder;
|
||||
import com.abin.mallchat.common.user.domain.enums.BlackTypeEnum;
|
||||
import com.abin.mallchat.common.user.domain.vo.response.ws.ChatMemberResp;
|
||||
import com.abin.mallchat.common.user.service.cache.UserCache;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 群聊相关接口
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/capi/chat")
|
||||
@Api(tags = "聊天室相关接口")
|
||||
@Slf4j
|
||||
public class ChatController {
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
@Autowired
|
||||
private UserCache userCache;
|
||||
|
||||
@GetMapping("/public/member/page")
|
||||
@ApiOperation("群成员列表(废弃)")
|
||||
@Deprecated
|
||||
@FrequencyControl(time = 120, count = 20, target = FrequencyControl.Target.IP)
|
||||
public ApiResult<CursorPageBaseResp<ChatMemberResp>> getMemberPage(@Valid MemberReq request) {
|
||||
CursorPageBaseResp<ChatMemberResp> memberPage = chatService.getMemberPage(null, request);
|
||||
filterBlackMember(memberPage);
|
||||
return ApiResult.success(memberPage);
|
||||
}
|
||||
|
||||
@GetMapping("/member/list")
|
||||
@ApiOperation("房间内的所有群成员列表-@专用(废弃)")
|
||||
@Deprecated
|
||||
public ApiResult<List<ChatMemberListResp>> getMemberList(@Valid ChatMessageMemberReq chatMessageMemberReq) {
|
||||
return ApiResult.success(chatService.getMemberList(chatMessageMemberReq));
|
||||
}
|
||||
|
||||
private void filterBlackMember(CursorPageBaseResp<ChatMemberResp> memberPage) {
|
||||
Set<String> blackMembers = getBlackUidSet();
|
||||
memberPage.getList().removeIf(a -> blackMembers.contains(a.getUid().toString()));
|
||||
}
|
||||
|
||||
private Set<String> getBlackUidSet() {
|
||||
return userCache.getBlackMap().getOrDefault(BlackTypeEnum.UID.getType(), new HashSet<>());
|
||||
}
|
||||
|
||||
@GetMapping("public/member/statistic")
|
||||
@ApiOperation("群成员人数统计")
|
||||
@Deprecated
|
||||
public ApiResult<ChatMemberStatisticResp> getMemberStatistic() {
|
||||
return ApiResult.success(chatService.getMemberStatistic());
|
||||
}
|
||||
|
||||
@GetMapping("/public/msg/page")
|
||||
@ApiOperation("消息列表")
|
||||
@FrequencyControl(time = 120, count = 20, target = FrequencyControl.Target.IP)
|
||||
public ApiResult<CursorPageBaseResp<ChatMessageResp>> getMsgPage(@Valid ChatMessagePageReq request) {
|
||||
CursorPageBaseResp<ChatMessageResp> msgPage = chatService.getMsgPage(request, RequestHolder.get().getUid());
|
||||
filterBlackMsg(msgPage);
|
||||
return ApiResult.success(msgPage);
|
||||
}
|
||||
|
||||
private void filterBlackMsg(CursorPageBaseResp<ChatMessageResp> memberPage) {
|
||||
Set<String> blackMembers = getBlackUidSet();
|
||||
memberPage.getList().removeIf(a -> blackMembers.contains(a.getFromUser().getUid().toString()));
|
||||
}
|
||||
|
||||
@PostMapping("/msg")
|
||||
@ApiOperation("发送消息")
|
||||
@FrequencyControl(time = 5, count = 3, target = FrequencyControl.Target.UID)
|
||||
@FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.UID)
|
||||
@FrequencyControl(time = 60, count = 10, target = FrequencyControl.Target.UID)
|
||||
public ApiResult<ChatMessageResp> sendMsg(@Valid @RequestBody ChatMessageReq request) {//todo 发送给单聊
|
||||
Long msgId = chatService.sendMsg(request, RequestHolder.get().getUid());
|
||||
//返回完整消息格式,方便前端展示
|
||||
return ApiResult.success(chatService.getMsgResp(msgId, RequestHolder.get().getUid()));
|
||||
}
|
||||
|
||||
@PutMapping("/msg/mark")
|
||||
@ApiOperation("消息标记")
|
||||
@FrequencyControl(time = 10, count = 5, target = FrequencyControl.Target.UID)
|
||||
public ApiResult<Void> setMsgMark(@Valid @RequestBody ChatMessageMarkReq request) {
|
||||
chatService.setMsgMark(RequestHolder.get().getUid(), request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
@PutMapping("/msg/recall")
|
||||
@ApiOperation("撤回消息")
|
||||
@FrequencyControl(time = 20, count = 3, target = FrequencyControl.Target.UID)
|
||||
public ApiResult<Void> recallMsg(@Valid @RequestBody ChatMessageBaseReq request) {
|
||||
chatService.recallMsg(RequestHolder.get().getUid(), request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/msg/read/page")
|
||||
@ApiOperation("消息的已读未读列表")
|
||||
public ApiResult<CursorPageBaseResp<ChatMessageReadResp>> getReadPage(@Valid ChatMessageReadReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(chatService.getReadPage(uid, request));
|
||||
}
|
||||
|
||||
@GetMapping("/msg/read")
|
||||
@ApiOperation("获取消息的已读未读总数")
|
||||
public ApiResult<Collection<MsgReadInfoDTO>> getReadInfo(@Valid ChatMessageReadInfoReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(chatService.getMsgReadInfo(uid, request));
|
||||
}
|
||||
|
||||
@PutMapping("/msg/read")
|
||||
@ApiOperation("消息阅读上报")
|
||||
public ApiResult<Void> msgRead(@Valid @RequestBody ChatMessageMemberReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
chatService.msgRead(uid, request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.abin.mallchat.common.chat.controller;
|
||||
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatRoomResp;
|
||||
import com.abin.mallchat.common.chat.service.ChatService;
|
||||
import com.abin.mallchat.common.chat.service.RoomAppService;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.IdReqVO;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.utils.RequestHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会话相关接口
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/capi/chat")
|
||||
@Api(tags = "聊天室相关接口")
|
||||
@Slf4j
|
||||
public class ContactController {
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
@Autowired
|
||||
private RoomAppService roomService;
|
||||
|
||||
@GetMapping("/public/contact/page")
|
||||
@ApiOperation("会话列表")
|
||||
public ApiResult<CursorPageBaseResp<ChatRoomResp>> getRoomPage(@Valid CursorPageBaseReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(roomService.getContactPage(request, uid));
|
||||
}
|
||||
|
||||
@GetMapping("/public/contact/detail")
|
||||
@ApiOperation("会话详情")
|
||||
public ApiResult<ChatRoomResp> getRoomPage(@Valid IdReqVO request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(roomService.getContactDetail(uid, request.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.abin.mallchat.common.chat.controller;
|
||||
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.vo.request.*;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.MemberResp;
|
||||
import com.abin.mallchat.common.chat.service.RoomAppService;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.IdReqVO;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.IdRespVO;
|
||||
import com.abin.mallchat.common.common.utils.RequestHolder;
|
||||
import com.abin.mallchat.common.user.domain.vo.response.ws.ChatMemberResp;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 房间相关接口
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/capi/room")
|
||||
@Api(tags = "聊天室相关接口")
|
||||
@Slf4j
|
||||
public class RoomController {
|
||||
@Autowired
|
||||
private RoomAppService roomService;
|
||||
|
||||
@GetMapping("/public/group")
|
||||
@ApiOperation("群组详情")
|
||||
public ApiResult<MemberResp> groupDetail(@Valid IdReqVO request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(roomService.getGroupDetail(uid, request.getId()));
|
||||
}
|
||||
|
||||
@GetMapping("/public/group/member/page")
|
||||
@ApiOperation("群成员列表")
|
||||
public ApiResult<CursorPageBaseResp<ChatMemberResp>> getMemberPage(@Valid MemberReq request) {
|
||||
return ApiResult.success(roomService.getMemberPage(request));
|
||||
}
|
||||
|
||||
@GetMapping("/group/member/list")
|
||||
@ApiOperation("房间内的所有群成员列表-@专用")
|
||||
public ApiResult<List<ChatMemberListResp>> getMemberList(@Valid ChatMessageMemberReq request) {
|
||||
return ApiResult.success(roomService.getMemberList(request));
|
||||
}
|
||||
|
||||
@DeleteMapping("/group/member")
|
||||
@ApiOperation("移除成员")
|
||||
public ApiResult<Void> delMember(@Valid @RequestBody MemberDelReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
roomService.delMember(uid, request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/group")
|
||||
@ApiOperation("新增群组")
|
||||
public ApiResult<IdRespVO> addGroup(@Valid @RequestBody GroupAddReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
Long roomId = roomService.addGroup(uid, request);
|
||||
return ApiResult.success(IdRespVO.id(roomId));
|
||||
}
|
||||
|
||||
@PostMapping("/group/member")
|
||||
@ApiOperation("邀请好友")
|
||||
public ApiResult<Void> addMember(@Valid @RequestBody MemberAddReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
roomService.addMember(uid, request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.Contact;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||
import com.abin.mallchat.common.chat.mapper.ContactMapper;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.utils.CursorUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会话列表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Service
|
||||
public class ContactDao extends ServiceImpl<ContactMapper, Contact> {
|
||||
|
||||
public Contact get(Long uid, Long roomId) {
|
||||
return lambdaQuery()
|
||||
.eq(Contact::getUid, uid)
|
||||
.eq(Contact::getRoomId, roomId)
|
||||
.one();
|
||||
}
|
||||
|
||||
public Integer getReadCount(Message message) {
|
||||
return lambdaQuery()
|
||||
.eq(Contact::getRoomId, message.getRoomId())
|
||||
.ne(Contact::getUid, message.getFromUid())//不需要查询出自己
|
||||
.ge(Contact::getReadTime, message.getCreateTime())
|
||||
.count();
|
||||
}
|
||||
|
||||
public Integer getTotalCount(Long roomId) {
|
||||
return lambdaQuery()
|
||||
.eq(Contact::getRoomId, roomId)
|
||||
.count();
|
||||
}
|
||||
|
||||
public Integer getUnReadCount(Message message) {
|
||||
return lambdaQuery()
|
||||
.eq(Contact::getRoomId, message.getRoomId())
|
||||
.lt(Contact::getReadTime, message.getCreateTime())
|
||||
.count();
|
||||
}
|
||||
|
||||
public CursorPageBaseResp<Contact> getReadPage(Message message, CursorPageBaseReq cursorPageBaseReq) {
|
||||
return CursorUtils.getCursorPageByMysql(this, cursorPageBaseReq, wrapper -> {
|
||||
wrapper.eq(Contact::getRoomId, message.getRoomId());
|
||||
wrapper.ne(Contact::getUid, message.getFromUid());//不需要查询出自己
|
||||
wrapper.ge(Contact::getReadTime, message.getCreateTime());//已读时间大于等于消息发送时间
|
||||
}, Contact::getReadTime);
|
||||
}
|
||||
|
||||
public CursorPageBaseResp<Contact> getUnReadPage(Message message, CursorPageBaseReq cursorPageBaseReq) {
|
||||
return CursorUtils.getCursorPageByMysql(this, cursorPageBaseReq, wrapper -> {
|
||||
wrapper.eq(Contact::getRoomId, message.getRoomId());
|
||||
wrapper.ne(Contact::getUid, message.getFromUid());//不需要查询出自己
|
||||
wrapper.lt(Contact::getReadTime, message.getCreateTime());//已读时间小于消息发送时间
|
||||
}, Contact::getReadTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户会话列表
|
||||
*/
|
||||
public CursorPageBaseResp<Contact> getContactPage(Long uid, CursorPageBaseReq request) {
|
||||
return CursorUtils.getCursorPageByMysql(this, request, wrapper -> {
|
||||
wrapper.eq(Contact::getUid, uid);
|
||||
}, Contact::getActiveTime);
|
||||
}
|
||||
|
||||
public List<Contact> getByRoomIds(List<Long> roomIds, Long uid) {
|
||||
return lambdaQuery()
|
||||
.eq(Contact::getRoomId, roomIds)
|
||||
.eq(Contact::getUid, uid)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新所有人的会话时间,没有就直接插入
|
||||
*/
|
||||
public void refreshOrCreateActiveTime(Long roomId, List<Long> memberUidList, Long msgId, Date activeTime) {
|
||||
baseMapper.refreshOrCreateActiveTime(roomId, memberUidList, msgId, activeTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.GroupMember;
|
||||
import com.abin.mallchat.common.chat.domain.enums.GroupRoleEnum;
|
||||
import com.abin.mallchat.common.chat.mapper.GroupMemberMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 群成员表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Service
|
||||
public class GroupMemberDao extends ServiceImpl<GroupMemberMapper, GroupMember> {
|
||||
|
||||
public List<Long> getMemberUidList(Long groupId) {
|
||||
List<GroupMember> list = lambdaQuery()
|
||||
.eq(GroupMember::getGroupId, groupId)
|
||||
.select(GroupMember::getUid)
|
||||
.list();
|
||||
return list.stream().map(GroupMember::getUid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Long> getMemberBatch(Long groupId, List<Long> uidList) {
|
||||
List<GroupMember> list = lambdaQuery()
|
||||
.eq(GroupMember::getGroupId, groupId)
|
||||
.in(GroupMember::getUid, uidList)
|
||||
.select(GroupMember::getUid)
|
||||
.list();
|
||||
return list.stream().map(GroupMember::getUid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public GroupMember getMember(Long groupId, Long uid) {
|
||||
return lambdaQuery()
|
||||
.eq(GroupMember::getGroupId, groupId)
|
||||
.eq(GroupMember::getUid, uid)
|
||||
.one();
|
||||
}
|
||||
|
||||
public List<GroupMember> getSelfGroup(Long uid) {
|
||||
return lambdaQuery()
|
||||
.eq(GroupMember::getUid, uid)
|
||||
.eq(GroupMember::getRole, GroupRoleEnum.LEADER.getType())
|
||||
.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
|
||||
import com.abin.mallchat.common.chat.mapper.MessageMapper;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.utils.CursorUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-03-25
|
||||
*/
|
||||
@Service
|
||||
public class MessageDao extends ServiceImpl<MessageMapper, Message> {
|
||||
|
||||
public CursorPageBaseResp<Message> getCursorPage(Long roomId, CursorPageBaseReq request, Long lastMsgId) {
|
||||
return CursorUtils.getCursorPageByMysql(this, request, wrapper -> {
|
||||
wrapper.eq(Message::getRoomId, roomId);
|
||||
wrapper.eq(Message::getStatus, MessageStatusEnum.NORMAL.getStatus());
|
||||
wrapper.le(Objects.nonNull(lastMsgId), Message::getId, lastMsgId);
|
||||
}, Message::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 乐观更新消息类型
|
||||
*/
|
||||
public boolean riseOptimistic(Long id, Integer oldType, Integer newType) {
|
||||
return lambdaUpdate()
|
||||
.eq(Message::getId, id)
|
||||
.eq(Message::getType, oldType)
|
||||
.set(Message::getType, newType)
|
||||
.update();
|
||||
}
|
||||
|
||||
public Integer getGapCount(Long roomId, Long fromId, Long toId) {
|
||||
return lambdaQuery()
|
||||
.eq(Message::getRoomId, roomId)
|
||||
.gt(Message::getId, fromId)
|
||||
.le(Message::getId, toId)
|
||||
.count();
|
||||
}
|
||||
|
||||
public void invalidByUid(Long uid) {
|
||||
lambdaUpdate()
|
||||
.eq(Message::getFromUid, uid)
|
||||
.set(Message::getStatus, MessageStatusEnum.DELETE.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
public Integer getUnReadCount(Long roomId, Date readTime) {
|
||||
return lambdaQuery()
|
||||
.eq(Message::getRoomId, roomId)
|
||||
.gt(Objects.nonNull(readTime), Message::getCreateTime, readTime)
|
||||
.count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.MessageMark;
|
||||
import com.abin.mallchat.common.chat.mapper.MessageMarkMapper;
|
||||
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息标记表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-04-08
|
||||
*/
|
||||
@Service
|
||||
public class MessageMarkDao extends ServiceImpl<MessageMarkMapper, MessageMark> {
|
||||
|
||||
public MessageMark get(Long uid, Long msgId, Integer markType) {
|
||||
return lambdaQuery().eq(MessageMark::getUid, uid)
|
||||
.eq(MessageMark::getMsgId, msgId)
|
||||
.eq(MessageMark::getType, markType)
|
||||
.one();
|
||||
}
|
||||
|
||||
public Integer getMarkCount(Long msgId, Integer markType) {
|
||||
return lambdaQuery().eq(MessageMark::getMsgId, msgId)
|
||||
.eq(MessageMark::getType, markType)
|
||||
.eq(MessageMark::getStatus, YesOrNoEnum.NO.getStatus())
|
||||
.count();
|
||||
}
|
||||
|
||||
public List<MessageMark> getValidMarkByMsgIdBatch(List<Long> msgIds) {
|
||||
return lambdaQuery()
|
||||
.in(MessageMark::getMsgId, msgIds)
|
||||
.eq(MessageMark::getStatus, YesOrNoEnum.NO.getStatus())
|
||||
.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.Room;
|
||||
import com.abin.mallchat.common.chat.mapper.RoomMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 房间表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Service
|
||||
public class RoomDao extends ServiceImpl<RoomMapper, Room> implements IService<Room> {
|
||||
|
||||
public void refreshActiveTime(Long roomId, Long msgId, Date msgTime) {
|
||||
lambdaUpdate()
|
||||
.eq(Room::getId, roomId)
|
||||
.set(Room::getLastMsgId, msgId)
|
||||
.set(Room::getActiveTime, msgTime)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.RoomFriend;
|
||||
import com.abin.mallchat.common.chat.mapper.RoomFriendMapper;
|
||||
import com.abin.mallchat.common.common.domain.enums.NormalOrNoEnum;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 单聊房间表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-22
|
||||
*/
|
||||
@Service
|
||||
public class RoomFriendDao extends ServiceImpl<RoomFriendMapper, RoomFriend> {
|
||||
|
||||
public RoomFriend getByKey(String key) {
|
||||
return lambdaQuery().eq(RoomFriend::getRoomKey, key).one();
|
||||
}
|
||||
|
||||
public void restoreRoom(Long id) {
|
||||
lambdaUpdate()
|
||||
.eq(RoomFriend::getId, id)
|
||||
.set(RoomFriend::getStatus, NormalOrNoEnum.NORMAL.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
public void disableRoom(String key) {
|
||||
lambdaUpdate()
|
||||
.eq(RoomFriend::getRoomKey, key)
|
||||
.set(RoomFriend::getStatus, NormalOrNoEnum.NOT_NORMAL.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
public List<RoomFriend> listByRoomIds(List<Long> roomIds) {
|
||||
return lambdaQuery()
|
||||
.in(RoomFriend::getRoomId, roomIds)
|
||||
.list();
|
||||
}
|
||||
|
||||
public RoomFriend getByRoomId(Long roomID) {
|
||||
return lambdaQuery()
|
||||
.eq(RoomFriend::getRoomId, roomID)
|
||||
.one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.RoomGroup;
|
||||
import com.abin.mallchat.common.chat.mapper.RoomGroupMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 群聊房间表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-22
|
||||
*/
|
||||
@Service
|
||||
public class RoomGroupDao extends ServiceImpl<RoomGroupMapper, RoomGroup> {
|
||||
|
||||
public List<RoomGroup> listByRoomIds(List<Long> roomIds) {
|
||||
return lambdaQuery()
|
||||
.in(RoomGroup::getRoomId, roomIds)
|
||||
.list();
|
||||
}
|
||||
|
||||
public RoomGroup getByRoomId(Long roomId) {
|
||||
return lambdaQuery()
|
||||
.eq(RoomGroup::getRoomId, roomId)
|
||||
.one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.abin.mallchat.common.chat.dao;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.WxMsg;
|
||||
import com.abin.mallchat.common.chat.mapper.WxMsgMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 微信消息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-05-16
|
||||
*/
|
||||
@Service
|
||||
public class WxMsgDao extends ServiceImpl<WxMsgMapper, WxMsg> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.abin.mallchat.common.chat.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Description: 消息标记请求
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageMarkDTO {
|
||||
|
||||
@ApiModelProperty("操作者")
|
||||
private Long uid;
|
||||
|
||||
@ApiModelProperty("消息id")
|
||||
private Long msgId;
|
||||
|
||||
/**
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum
|
||||
*/
|
||||
@ApiModelProperty("标记类型 1点赞 2举报")
|
||||
private Integer markType;
|
||||
|
||||
/**
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageMarkActTypeEnum
|
||||
*/
|
||||
@ApiModelProperty("动作类型 1确认 2取消")
|
||||
private Integer actType;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.abin.mallchat.common.chat.domain.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Description:消息撤回的推送类
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMsgRecallDTO {
|
||||
private Long msgId;
|
||||
private Long roomId;
|
||||
//撤回的用户
|
||||
private Long recallUid;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.abin.mallchat.common.chat.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MsgReadInfoDTO {
|
||||
@ApiModelProperty("消息id")
|
||||
private Long msgId;
|
||||
|
||||
@ApiModelProperty("已读数")
|
||||
private Integer readCount;
|
||||
|
||||
@ApiModelProperty("未读数")
|
||||
private Integer unReadCount;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.abin.mallchat.common.chat.domain.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Description: 房间详情
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class RoomBaseInfo {
|
||||
@ApiModelProperty("房间id")
|
||||
private Long roomId;
|
||||
@ApiModelProperty("会话名称")
|
||||
private String name;
|
||||
@ApiModelProperty("会话头像")
|
||||
private String avatar;
|
||||
/**
|
||||
* 房间类型 1群聊 2单聊
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 是否全员展示 0否 1是
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.HotFlagEnum
|
||||
*/
|
||||
private Integer hotFlag;
|
||||
|
||||
/**
|
||||
* 群最后消息的更新时间
|
||||
*/
|
||||
@TableField("active_time")
|
||||
private Date activeTime;
|
||||
|
||||
/**
|
||||
* 最后一条消息id
|
||||
*/
|
||||
@TableField("last_msg_id")
|
||||
private Long lastMsgId;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会话列表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("contact")
|
||||
public class Contact implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* uid
|
||||
*/
|
||||
@TableField("uid")
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 房间id
|
||||
*/
|
||||
@TableField("room_id")
|
||||
private Long roomId;
|
||||
|
||||
/**
|
||||
* 阅读到的时间
|
||||
*/
|
||||
@TableField("read_time")
|
||||
private Date readTime;
|
||||
|
||||
/**
|
||||
* 会话内消息最后更新的时间(只有普通会话需要维护,全员会话不需要维护)
|
||||
*/
|
||||
@TableField("active_time")
|
||||
private Date activeTime;
|
||||
|
||||
/**
|
||||
* 最后一条消息id
|
||||
*/
|
||||
@TableField("last_msg_id")
|
||||
private Long lastMsgId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 群成员表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("group_member")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GroupMember implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 群组id
|
||||
*/
|
||||
@TableField("group_id")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 成员uid
|
||||
*/
|
||||
@TableField("uid")
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 成员角色1群主(可撤回,可移除,可解散) 2管理员(可撤回,可移除) 3普通成员
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.GroupRoleEnum
|
||||
*/
|
||||
@TableField("role")
|
||||
private Integer role;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.entity.msg.MessageExtra;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-03-25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName(value = "message", autoResultMap = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Message implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会话表id
|
||||
*/
|
||||
@TableField("room_id")
|
||||
private Long roomId;
|
||||
|
||||
/**
|
||||
* 消息发送者uid
|
||||
*/
|
||||
@TableField("from_uid")
|
||||
private Long fromUid;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 回复的消息内容
|
||||
*/
|
||||
@TableField("reply_msg_id")
|
||||
private Long replyMsgId;
|
||||
|
||||
/**
|
||||
* 消息状态 0正常 1删除
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 与回复消息的间隔条数
|
||||
*/
|
||||
@TableField("gap_count")
|
||||
private Integer gapCount;
|
||||
|
||||
/**
|
||||
* 消息类型 1正常文本 2.撤回消息
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum
|
||||
*/
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消息扩展字段
|
||||
*/
|
||||
@TableField(value = "extra", typeHandler = JacksonTypeHandler.class)
|
||||
private MessageExtra extra;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息标记表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-04-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("message_mark")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageMark implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 消息表id
|
||||
*/
|
||||
@TableField("msg_id")
|
||||
private Long msgId;
|
||||
|
||||
/**
|
||||
* 标记人uid
|
||||
*/
|
||||
@TableField("uid")
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 标记类型 1点赞 2举报
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum
|
||||
*/
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消息状态 0正常 1取消
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.enums.HotFlagEnum;
|
||||
import com.abin.mallchat.common.chat.domain.enums.RoomTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 房间表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("room")
|
||||
public class Room implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 房间类型 1群聊 2单聊
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.RoomTypeEnum
|
||||
*/
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 是否全员展示 0否 1是
|
||||
*
|
||||
* @see com.abin.mallchat.common.chat.domain.enums.HotFlagEnum
|
||||
*/
|
||||
@TableField("hot_flag")
|
||||
private Integer hotFlag;
|
||||
|
||||
/**
|
||||
* 群最后消息的更新时间(热点群不需要写扩散,更新这里就行)
|
||||
*/
|
||||
@TableField("active_time")
|
||||
private Date activeTime;
|
||||
|
||||
/**
|
||||
* 最后一条消息id
|
||||
*/
|
||||
@TableField("last_msg_id")
|
||||
private Long lastMsgId;
|
||||
|
||||
/**
|
||||
* 额外信息(根据不同类型房间有不同存储的东西)
|
||||
*/
|
||||
@TableField("ext_json")
|
||||
private String extJson;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isHotRoom() {
|
||||
return HotFlagEnum.of(this.hotFlag) == HotFlagEnum.YES;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isRoomFriend() {
|
||||
return RoomTypeEnum.of(this.type) == RoomTypeEnum.FRIEND;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isRoomGroup() {
|
||||
return RoomTypeEnum.of(this.hotFlag) == RoomTypeEnum.GROUP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 单聊房间表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("room_friend")
|
||||
public class RoomFriend implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 房间id
|
||||
*/
|
||||
@TableField("room_id")
|
||||
private Long roomId;
|
||||
|
||||
/**
|
||||
* uid1(更小的uid)
|
||||
*/
|
||||
@TableField("uid1")
|
||||
private Long uid1;
|
||||
|
||||
/**
|
||||
* uid2(更大的uid)
|
||||
*/
|
||||
@TableField("uid2")
|
||||
private Long uid2;
|
||||
|
||||
/**
|
||||
* 房间key由两个uid拼接,先做排序uid1_uid2
|
||||
*/
|
||||
@TableField("room_key")
|
||||
private String roomKey;
|
||||
|
||||
/**
|
||||
* 房间状态 0正常 1禁用(删好友了禁用)
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 群聊房间表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("room_group")
|
||||
public class RoomGroup implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 房间id
|
||||
*/
|
||||
@TableField("room_id")
|
||||
private Long roomId;
|
||||
|
||||
/**
|
||||
* 群名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 群头像
|
||||
*/
|
||||
@TableField("avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 额外信息(根据不同类型房间有不同存储的东西)
|
||||
*/
|
||||
@TableField("ext_json")
|
||||
private String extJson;
|
||||
|
||||
/**
|
||||
* 逻辑删除(0-正常,1-删除)
|
||||
*/
|
||||
@TableField("delete_status")
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer deleteStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 微信消息表
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* @since 2023-05-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("wx_msg")
|
||||
public class WxMsg implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 微信openid用户标识
|
||||
*/
|
||||
@TableField("open_id")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 用户消息
|
||||
*/
|
||||
@TableField("msg")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description: 表情图片消息入参
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EmojisMsgDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("下载地址")
|
||||
@NotBlank
|
||||
private String url;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description: 语音消息入参
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileMsgDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("大小(字节)")
|
||||
@NotNull
|
||||
private Long size;
|
||||
|
||||
@ApiModelProperty("下载地址")
|
||||
@NotBlank
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty("文件名(带后缀)")
|
||||
@NotBlank
|
||||
private String fileName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description: 图片消息入参
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ImgMsgDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("大小(字节)")
|
||||
@NotNull
|
||||
private Long size;
|
||||
|
||||
@ApiModelProperty("宽度(像素)")
|
||||
@NotNull
|
||||
private Integer width;
|
||||
|
||||
@ApiModelProperty("高度(像素)")
|
||||
@NotNull
|
||||
private Integer height;
|
||||
|
||||
@ApiModelProperty("下载地址")
|
||||
@NotBlank
|
||||
private String url;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import com.abin.mallchat.common.common.utils.discover.domain.UrlInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description: 消息扩展属性
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-05-28
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MessageExtra implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//url跳转链接
|
||||
private Map<String, UrlInfo> urlContentMap;
|
||||
//消息撤回详情
|
||||
private MsgRecall recall;
|
||||
//艾特的uid
|
||||
private List<Long> atUidList;
|
||||
//文件消息
|
||||
private FileMsgDTO fileMsg;
|
||||
//图片消息
|
||||
private ImgMsgDTO imgMsgDTO;
|
||||
//语音消息
|
||||
private SoundMsgDTO soundMsgDTO;
|
||||
//文件消息
|
||||
private VideoMsgDTO videoMsgDTO;
|
||||
|
||||
/**
|
||||
* 表情图片信息
|
||||
*/
|
||||
private EmojisMsgDTO emojisMsgDTO;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Description: 消息撤回
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MsgRecall implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//撤回消息的uid
|
||||
private Long recallUid;
|
||||
//撤回的时间点
|
||||
private Date recallTime;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description: 语音消息入参
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SoundMsgDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("大小(字节)")
|
||||
@NotNull
|
||||
private Long size;
|
||||
|
||||
@ApiModelProperty("时长(秒)")
|
||||
@NotNull
|
||||
private Integer second;
|
||||
|
||||
@ApiModelProperty("下载地址")
|
||||
@NotBlank
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.abin.mallchat.common.chat.domain.entity.msg;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description: 视频消息入参
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-06-04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VideoMsgDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("大小(字节)")
|
||||
@NotNull
|
||||
private Long size;
|
||||
|
||||
@ApiModelProperty("下载地址")
|
||||
@NotBlank
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty("缩略图宽度(像素)")
|
||||
@NotNull
|
||||
private Integer thumbWidth;
|
||||
|
||||
@ApiModelProperty("缩略图高度(像素)")
|
||||
@NotNull
|
||||
private Integer thumbHeight;
|
||||
|
||||
@ApiModelProperty("缩略图大小(字节)")
|
||||
@NotNull
|
||||
private Long thumbSize;
|
||||
|
||||
@ApiModelProperty("缩略图下载地址")
|
||||
@NotBlank
|
||||
private String thumbUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 热点枚举
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum GroupRoleAPPEnum {
|
||||
LEADER(1, "群主"),
|
||||
MANAGER(2, "管理"),
|
||||
MEMBER(3, "普通成员"),
|
||||
REMOVE(4, "被移除的成员"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, GroupRoleAPPEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(GroupRoleAPPEnum.values()).collect(Collectors.toMap(GroupRoleAPPEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static GroupRoleAPPEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 成员角色枚举
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum GroupRoleEnum {
|
||||
LEADER(1, "群主"),
|
||||
MANAGER(2, "管理"),
|
||||
MEMBER(3, "普通成员"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, GroupRoleEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(GroupRoleEnum.values()).collect(Collectors.toMap(GroupRoleEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static GroupRoleEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 热点枚举
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HotFlagEnum {
|
||||
NOT(0, "非热点"),
|
||||
YES(1, "热点"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, HotFlagEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(HotFlagEnum.values()).collect(Collectors.toMap(HotFlagEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static HotFlagEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息标记动作类型
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageMarkActTypeEnum {
|
||||
MARK(1, "确认标记"),
|
||||
UN_MARK(2, "取消标记"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, MessageMarkActTypeEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageMarkActTypeEnum.values()).collect(Collectors.toMap(MessageMarkActTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static MessageMarkActTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息标记类型
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageMarkTypeEnum {
|
||||
LIKE(1, "点赞", 10),
|
||||
DISLIKE(2, "点踩", 5),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
private final Integer riseNum;//需要多少个标记升级
|
||||
|
||||
private static Map<Integer, MessageMarkTypeEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageMarkTypeEnum.values()).collect(Collectors.toMap(MessageMarkTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static MessageMarkTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息状态
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageStatusEnum {
|
||||
NORMAL(0, "正常"),
|
||||
DELETE(1, "删除"),
|
||||
;
|
||||
|
||||
private final Integer status;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, MessageStatusEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageStatusEnum.values()).collect(Collectors.toMap(MessageStatusEnum::getStatus, Function.identity()));
|
||||
}
|
||||
|
||||
public static MessageStatusEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息状态
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MessageTypeEnum {
|
||||
TEXT(1, "正常消息"),
|
||||
RECALL(2, "撤回消息"),
|
||||
IMG(3, "图片"),
|
||||
FILE(4, "文件"),
|
||||
SOUND(5, "语音"),
|
||||
VIDEO(6, "视频"),
|
||||
EMOJI(7, "表情"),
|
||||
SYSTEM(8, "系统消息"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, MessageTypeEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(MessageTypeEnum.values()).collect(Collectors.toMap(MessageTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static MessageTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.abin.mallchat.common.chat.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 消息状态
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum RoomTypeEnum {
|
||||
GROUP(1, "群聊"),
|
||||
FRIEND(2, "单聊"),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
private static Map<Integer, RoomTypeEnum> cache;
|
||||
|
||||
static {
|
||||
cache = Arrays.stream(RoomTypeEnum.values()).collect(Collectors.toMap(RoomTypeEnum::getType, Function.identity()));
|
||||
}
|
||||
|
||||
public static RoomTypeEnum of(Integer type) {
|
||||
return cache.get(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* Description: 消息基础请求体
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-23
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageBaseReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("消息id")
|
||||
private Long msgId;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("会话id")
|
||||
private Long roomId;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Description: 消息标记请求
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageMarkReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("消息id")
|
||||
private Long msgId;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("标记类型 1点赞 2举报")
|
||||
private Integer markType;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("动作类型 1确认 2取消")
|
||||
private Integer actType;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Description: 消息列表请求
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageMemberReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("会话id")
|
||||
private Long roomId;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Description: 消息列表请求
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessagePageReq extends CursorPageBaseReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("会话id")
|
||||
private Long roomId;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageReadInfoReq {
|
||||
@ApiModelProperty("消息id集合(只查本人)")
|
||||
@Size(max = 20)
|
||||
private List<Long> msgIds;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageReadReq extends CursorPageBaseReq {
|
||||
@ApiModelProperty("消息id")
|
||||
@NotNull
|
||||
private Long msgId;
|
||||
|
||||
@ApiModelProperty("查询类型 1已读 2未读")
|
||||
@NotNull
|
||||
private Long searchType;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* 聊天信息点播
|
||||
* Description: 消息发送请求体
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-23
|
||||
*
|
||||
* @author zhaoyuhang
|
||||
* @date 2023/06/30
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessageReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("房间id")
|
||||
private Long roomId;
|
||||
|
||||
@ApiModelProperty("消息类型")
|
||||
@NotNull
|
||||
private Integer msgType;
|
||||
|
||||
@ApiModelProperty("消息内容,类型不同传值不同,见https://www.yuque.com/snab/mallcaht/rkb2uz5k1qqdmcmd")
|
||||
@NotNull
|
||||
private Object body;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: 新建群组
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GroupAddReq {
|
||||
@NotNull
|
||||
@Size(min = 1, max = 50)
|
||||
@ApiModelProperty("邀请的uid")
|
||||
private List<Long> uidList;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.abin.mallchat.common.chat.domain.vo.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: 移除群成员
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MemberAddReq {
|
||||
@NotNull
|
||||
@ApiModelProperty("房间id")
|
||||
private Long roomId;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 50)
|
||||
@ApiModelProperty("邀请的uid")
|
||||
private List<Long> uidList;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user