Compare commits
2 Commits
21c0a94a5d
...
a4e66b39d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4e66b39d1 | ||
|
|
0a1425c7ab |
@@ -4,11 +4,32 @@ import org.mybatis.spring.annotation.MapperScan;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
@MapperScan("com.bao.dating.mapper")
|
@MapperScan("com.bao.dating.mapper")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class DatingApplication {
|
public class DatingApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(DatingApplication.class, args);
|
SpringApplication.run(DatingApplication.class, args);
|
||||||
|
// 读取并打印 ciallo.txt 文件内容
|
||||||
|
printCialloFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 读取并打印 ciallo.txt 文件内容
|
||||||
|
*/
|
||||||
|
private static void printCialloFile() {
|
||||||
|
try (InputStream inputStream = DatingApplication.class.getClassLoader().getResourceAsStream("ciallo.txt");
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("读取 ciallo.txt 文件时发生错误: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class ChatWebSocketHandler extends TextWebSocketHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户建立连接(上线)
|
* 用户建立连接(上线)
|
||||||
* @param session
|
* @param session WebSocketSession
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) {
|
public void afterConnectionEstablished(WebSocketSession session) {
|
||||||
@@ -46,8 +46,8 @@ public class ChatWebSocketHandler extends TextWebSocketHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收并处理消息
|
* 接收并处理消息
|
||||||
* @param session
|
* @param session WebSocketSession
|
||||||
* @param message
|
* @param message 消息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception{
|
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception{
|
||||||
@@ -100,8 +100,8 @@ public class ChatWebSocketHandler extends TextWebSocketHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户断开连接(下线)
|
* 用户断开连接(下线)
|
||||||
* @param session
|
* @param session WebSocketSession
|
||||||
* @param status
|
* @param status 断开原因
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status){
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus status){
|
||||||
|
|||||||
@@ -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()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/main/resources/ciallo.txt
Normal file
9
src/main/resources/ciallo.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
▄▄▄▄ ██ ▄▄▄▄ ▄▄▄▄ ▄▄ ▄▄
|
||||||
|
██▀▀▀▀█ ▀▀ ▀▀██ ▀▀██ ██ ▄▄ ██
|
||||||
|
██▀ ████ ▄█████▄ ██ ██ ▄████▄ ▄▄▄ ▄█▀ ▄█▀ ██ █▄ ▄▄▄█ ▀█▄ ▄▄▄▄
|
||||||
|
██ ██ ▀ ▄▄▄██ ██ ██ ██▀ ▀██ ▀ ▀▀▄▄ ▄ ██ ▄█▀ ██ ██ ██ ▄▄█▀▀▀ ██ █▀▀ ▀█▄ █▄
|
||||||
|
██▄ ██ ▄██▀▀▀██ ██ ██ ██ ██ ▀▀▀ ██ ▄█▄▄▄▄▄ ▀▀ ██ ██ ██ ▀▀█▄▄▄ ██ █▀ █ ▀▀████▀
|
||||||
|
██▄▄▄▄█ ▄▄▄██▄▄▄ ██▄▄▄███ ██▄▄▄ ██▄▄▄ ▀██▄▄██▀ ▀█▄ ▀▀▀▀▀▀▀▀ ██▄██▄██ ▀▀▀█ ▄█▀ █▀▀█
|
||||||
|
▀▀▀▀ ▀▀▀▀▀▀▀▀ ▀▀▀▀ ▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ██ ▀▀▀ ▀▀▀ ██
|
||||||
|
▀▀ ▀▀
|
||||||
@@ -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