完成会话状态更新、置顶状态更新、免打扰状态更新
This commit is contained in:
@@ -4,8 +4,7 @@ import com.bao.dating.common.Result;
|
|||||||
import com.bao.dating.common.ResultCode;
|
import com.bao.dating.common.ResultCode;
|
||||||
import com.bao.dating.common.result.PageResult;
|
import com.bao.dating.common.result.PageResult;
|
||||||
import com.bao.dating.context.UserContext;
|
import com.bao.dating.context.UserContext;
|
||||||
import com.bao.dating.pojo.dto.ChatCursorPageDTO;
|
import com.bao.dating.pojo.dto.*;
|
||||||
import com.bao.dating.pojo.dto.ChatHistoryQueryDTO;
|
|
||||||
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
||||||
import com.bao.dating.pojo.vo.ChatSessionsVO;
|
import com.bao.dating.pojo.vo.ChatSessionsVO;
|
||||||
import com.bao.dating.service.ChatService;
|
import com.bao.dating.service.ChatService;
|
||||||
@@ -57,4 +56,37 @@ public class ChatController {
|
|||||||
List<ChatSessionsVO> list = chatService.getSessionList(currentUserId);
|
List<ChatSessionsVO> list = chatService.getSessionList(currentUserId);
|
||||||
return Result.success(ResultCode.SUCCESS, "获取会话列表成功", list);
|
return Result.success(ResultCode.SUCCESS, "获取会话列表成功", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话状态
|
||||||
|
* @param dto 会话状态
|
||||||
|
* @return 无
|
||||||
|
*/
|
||||||
|
@PostMapping("/session/status")
|
||||||
|
public Result<Void> updateSessionStatus(@RequestBody ChatSessionStatusDTO dto) {
|
||||||
|
chatService.updateSessionStatus(UserContext.getUserId(), dto);
|
||||||
|
return Result.success(ResultCode.SUCCESS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 置顶会话
|
||||||
|
* @param dto 置顶状态
|
||||||
|
* @return 无
|
||||||
|
*/
|
||||||
|
@PostMapping("/session/top")
|
||||||
|
public Result<Void> updateTopStatus(@RequestBody ChatSessionTopDTO dto) {
|
||||||
|
chatService.updateTopStatus(UserContext.getUserId(), dto);
|
||||||
|
return Result.success(ResultCode.SUCCESS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 静音会话
|
||||||
|
* @param dto 静音状态
|
||||||
|
* @return 无
|
||||||
|
*/
|
||||||
|
@PostMapping("/session/mute")
|
||||||
|
public Result<Void> updateMuteStatus(@RequestBody ChatSessionMuteDTO dto) {
|
||||||
|
chatService.updateMuteStatus(UserContext.getUserId(), dto);
|
||||||
|
return Result.success(ResultCode.SUCCESS, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,37 @@ public interface ChatSessionsMapper {
|
|||||||
* @return 会话列表
|
* @return 会话列表
|
||||||
*/
|
*/
|
||||||
List<ChatSessions> selectSessionsByUserId(@Param("userId") Long userId);
|
List<ChatSessions> selectSessionsByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话状态
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param targetUserId 目标用户ID
|
||||||
|
* @param sessionStatus 会话状态
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int updateSessionStatus(@Param("userId") Long userId,
|
||||||
|
@Param("targetUserId") Long targetUserId,
|
||||||
|
@Param("sessionStatus") Integer sessionStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话置顶状态
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param targetUserId 目标用户ID
|
||||||
|
* @param topStatus 置顶状态
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int updateTopStatus(@Param("userId") Long userId,
|
||||||
|
@Param("targetUserId") Long targetUserId,
|
||||||
|
@Param("topStatus") Integer topStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话免打扰状态
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param targetUserId 目标用户ID
|
||||||
|
* @param muteStatus 免打扰状态
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int updateMuteStatus(@Param("userId") Long userId,
|
||||||
|
@Param("targetUserId") Long targetUserId,
|
||||||
|
@Param("muteStatus") Integer muteStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.bao.dating.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聊天会话静音参数
|
||||||
|
* @author lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ChatSessionMuteDTO {
|
||||||
|
private Long targetUserId;
|
||||||
|
private Integer muteStatus;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.bao.dating.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话状态参数
|
||||||
|
* @author lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ChatSessionStatusDTO {
|
||||||
|
private Long targetUserId;
|
||||||
|
private Integer sessionStatus;
|
||||||
|
}
|
||||||
13
src/main/java/com/bao/dating/pojo/dto/ChatSessionTopDTO.java
Normal file
13
src/main/java/com/bao/dating/pojo/dto/ChatSessionTopDTO.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.bao.dating.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话置顶参数
|
||||||
|
* @author lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ChatSessionTopDTO {
|
||||||
|
private Long targetUserId;
|
||||||
|
private Integer topStatus;
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.bao.dating.service;
|
package com.bao.dating.service;
|
||||||
|
|
||||||
import com.bao.dating.common.result.PageResult;
|
import com.bao.dating.common.result.PageResult;
|
||||||
import com.bao.dating.pojo.dto.ChatHistoryQueryDTO;
|
import com.bao.dating.pojo.dto.*;
|
||||||
import com.bao.dating.pojo.dto.ChatRecordSendDTO;
|
|
||||||
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
||||||
import com.bao.dating.pojo.vo.ChatSessionsVO;
|
import com.bao.dating.pojo.vo.ChatSessionsVO;
|
||||||
|
|
||||||
@@ -43,4 +42,25 @@ public interface ChatService {
|
|||||||
* @return 会话列表
|
* @return 会话列表
|
||||||
*/
|
*/
|
||||||
List<ChatSessionsVO> getSessionList(Long currentUserId);
|
List<ChatSessionsVO> getSessionList(Long currentUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话状态
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 更新参数
|
||||||
|
*/
|
||||||
|
void updateSessionStatus(Long userId, ChatSessionStatusDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 置顶会话
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 置顶参数
|
||||||
|
*/
|
||||||
|
void updateTopStatus(Long userId, ChatSessionTopDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免打扰会话
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 免打扰参数
|
||||||
|
*/
|
||||||
|
void updateMuteStatus(Long userId, ChatSessionMuteDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package com.bao.dating.service.impl;
|
|||||||
|
|
||||||
import com.bao.dating.mapper.ChatRecordsMapper;
|
import com.bao.dating.mapper.ChatRecordsMapper;
|
||||||
import com.bao.dating.mapper.ChatSessionsMapper;
|
import com.bao.dating.mapper.ChatSessionsMapper;
|
||||||
import com.bao.dating.pojo.dto.ChatHistoryQueryDTO;
|
import com.bao.dating.pojo.dto.*;
|
||||||
import com.bao.dating.pojo.dto.ChatMarkReadDTO;
|
|
||||||
import com.bao.dating.pojo.dto.ChatRecordSendDTO;
|
|
||||||
import com.bao.dating.pojo.dto.UserInfoDTO;
|
|
||||||
import com.bao.dating.pojo.entity.ChatRecords;
|
import com.bao.dating.pojo.entity.ChatRecords;
|
||||||
import com.bao.dating.pojo.entity.ChatSessions;
|
import com.bao.dating.pojo.entity.ChatSessions;
|
||||||
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
import com.bao.dating.pojo.vo.ChatRecordsVO;
|
||||||
@@ -183,4 +180,45 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会话状态
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 会话状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateSessionStatus(Long userId, ChatSessionStatusDTO dto) {
|
||||||
|
chatSessionsMapper.updateSessionStatus(
|
||||||
|
userId,
|
||||||
|
dto.getTargetUserId(),
|
||||||
|
dto.getSessionStatus()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 置顶会话
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 置顶状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateTopStatus(Long userId, ChatSessionTopDTO dto) {
|
||||||
|
chatSessionsMapper.updateTopStatus(
|
||||||
|
userId,
|
||||||
|
dto.getTargetUserId(),
|
||||||
|
dto.getTopStatus()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免打扰会话
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param dto 免打扰状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateMuteStatus(Long userId, ChatSessionMuteDTO dto) {
|
||||||
|
chatSessionsMapper.updateMuteStatus(
|
||||||
|
userId,
|
||||||
|
dto.getTargetUserId(),
|
||||||
|
dto.getMuteStatus()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,32 @@
|
|||||||
AND session_status in (1,2)
|
AND session_status in (1,2)
|
||||||
ORDER BY top_status DESC, last_message_time DESC
|
ORDER BY top_status DESC, last_message_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 更新会话状态 -->
|
||||||
|
<update id="updateSessionStatus">
|
||||||
|
UPDATE chat_sessions
|
||||||
|
SET session_status = #{sessionStatus},
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE user_id = #{userId}
|
||||||
|
AND target_user_id = #{targetUserId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 置顶会话 -->
|
||||||
|
<update id="updateTopStatus">
|
||||||
|
UPDATE chat_sessions
|
||||||
|
SET top_status = #{topStatus},
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE user_id = #{userId}
|
||||||
|
AND target_user_id = #{targetUserId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 静音会话 -->
|
||||||
|
<update id="updateMuteStatus">
|
||||||
|
UPDATE chat_sessions
|
||||||
|
SET mute_status = #{muteStatus},
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE user_id = #{userId}
|
||||||
|
AND target_user_id = #{targetUserId}
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user