mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2025-12-26 04:47:53 +08:00
fix:联系人直接发消息
This commit is contained in:
parent
17bf39e37d
commit
2cd03adbe9
@ -187,6 +187,9 @@ CREATE TABLE `user_role` (
|
||||
KEY `idx_update_time` (`update_time`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户角色关系表';
|
||||
|
||||
insert into role(id,`name`) values(1,'超级管理员');
|
||||
insert into role(id,`name`) values(2,'抹茶群聊管理员');
|
||||
|
||||
DROP TABLE IF EXISTS `sensitive_word`;
|
||||
CREATE TABLE `sensitive_word` (
|
||||
`word` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '敏感词'
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.abin.mallchat.common.chat.controller;
|
||||
|
||||
|
||||
import com.abin.mallchat.common.chat.domain.vo.request.ContactFriendReq;
|
||||
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;
|
||||
@ -46,9 +47,16 @@ public class ContactController {
|
||||
|
||||
@GetMapping("/public/contact/detail")
|
||||
@ApiOperation("会话详情")
|
||||
public ApiResult<ChatRoomResp> getRoomPage(@Valid IdReqVO request) {
|
||||
public ApiResult<ChatRoomResp> getContactDetail(@Valid IdReqVO request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(roomService.getContactDetail(uid, request.getId()));
|
||||
}
|
||||
|
||||
@GetMapping("/public/contact/detail/friend")
|
||||
@ApiOperation("会话详情(联系人列表发消息用)")
|
||||
public ApiResult<ChatRoomResp> getContactDetailByFriend(@Valid ContactFriendReq request) {
|
||||
Long uid = RequestHolder.get().getUid();
|
||||
return ApiResult.success(roomService.getContactDetailByFriend(uid, request.getUid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.NotNull;
|
||||
|
||||
/**
|
||||
* Description: 移除群成员
|
||||
* Author: <a href="https://github.com/zongzibinbin">abin</a>
|
||||
* Date: 2023-03-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ContactFriendReq {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty("好友uid")
|
||||
private Long uid;
|
||||
}
|
||||
@ -37,4 +37,6 @@ public interface RoomAppService {
|
||||
Long addGroup(Long uid, GroupAddReq request);
|
||||
|
||||
ChatRoomResp getContactDetail(Long uid, Long roomId);
|
||||
|
||||
ChatRoomResp getContactDetailByFriend(Long uid, Long friendUid);
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@ public interface RoomService {
|
||||
*/
|
||||
RoomFriend createFriendRoom(List<Long> uidList);
|
||||
|
||||
RoomFriend getFriendRoom(Long uid1, Long uid2);
|
||||
|
||||
/**
|
||||
* 禁用一个单聊房间
|
||||
*/
|
||||
@ -27,4 +29,6 @@ public interface RoomService {
|
||||
* 创建一个群聊房间
|
||||
*/
|
||||
RoomGroup createGroupRoom(Long uid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -127,6 +127,13 @@ public class RoomAppServiceImpl implements RoomAppService {
|
||||
return buildContactResp(uid, Collections.singletonList(roomId)).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatRoomResp getContactDetailByFriend(Long uid, Long friendUid) {
|
||||
RoomFriend friendRoom = roomService.getFriendRoom(uid, friendUid);
|
||||
AssertUtil.isNotEmpty(friendRoom, "他不是您的好友");
|
||||
return buildContactResp(uid, Collections.singletonList(friendRoom.getRoomId())).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberResp getGroupDetail(Long uid, long roomId) {
|
||||
RoomGroup roomGroup = roomGroupCache.get(roomId);
|
||||
|
||||
@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -59,6 +60,12 @@ public class RoomServiceImpl implements RoomService {
|
||||
return roomFriend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomFriend getFriendRoom(Long uid1, Long uid2) {
|
||||
String key = ChatAdapter.generateRoomKey(Arrays.asList(uid1, uid2));
|
||||
return roomFriendDao.getByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableFriendRoom(List<Long> uidList) {
|
||||
AssertUtil.isNotEmpty(uidList, "房间创建失败,好友数量不对");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user