|
@@ -14,6 +14,7 @@ import com.kioor.common.exception.ErrorCode;
|
|
import com.kioor.common.exception.RenException;
|
|
import com.kioor.common.exception.RenException;
|
|
import com.kioor.common.redis.RedisKeys;
|
|
import com.kioor.common.redis.RedisKeys;
|
|
import com.kioor.common.redis.RedisUtils;
|
|
import com.kioor.common.redis.RedisUtils;
|
|
|
|
+import com.kioor.common.utils.DateUtils;
|
|
import com.kioor.common.utils.JsonUtils;
|
|
import com.kioor.common.utils.JsonUtils;
|
|
import com.kioor.room.dto.RoomDTO;
|
|
import com.kioor.room.dto.RoomDTO;
|
|
import com.kioor.room.service.UserHousingEstateService;
|
|
import com.kioor.room.service.UserHousingEstateService;
|
|
@@ -139,11 +140,15 @@ public class WebSocketServer {
|
|
@OnMessage
|
|
@OnMessage
|
|
public void onMessage(Session session, String msg) {
|
|
public void onMessage(Session session, String msg) {
|
|
log.info("session id: " + session.getId() + ", message:" + msg);
|
|
log.info("session id: " + session.getId() + ", message:" + msg);
|
|
|
|
+ if(msg.equals("ping")){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
RedisUtils redisUtils = applicationContext.getBean(RedisUtils.class);
|
|
RedisUtils redisUtils = applicationContext.getBean(RedisUtils.class);
|
|
//msg Json字符串转为MsgWebSocket对象
|
|
//msg Json字符串转为MsgWebSocket对象
|
|
MsgWebSocket fromMsgDetail = JsonUtils.parseObject(msg, MsgWebSocket.class);
|
|
MsgWebSocket fromMsgDetail = JsonUtils.parseObject(msg, MsgWebSocket.class);
|
|
if (fromMsgDetail != null && fromMsgDetail.getToId() != null) {
|
|
if (fromMsgDetail != null && fromMsgDetail.getToId() != null) {
|
|
-
|
|
|
|
|
|
+ Date editTime = new Date();
|
|
|
|
+ fromMsgDetail.setEditTimeStr(DateUtils.format(editTime, DateUtils.DATE_TIME_PATTERN));
|
|
MessageData<String> message = new MessageData<String>().msg(msg);
|
|
MessageData<String> message = new MessageData<String>().msg(msg);
|
|
switch(fromMsgDetail.getToType()){
|
|
switch(fromMsgDetail.getToType()){
|
|
case 0:
|
|
case 0:
|
|
@@ -156,7 +161,7 @@ public class WebSocketServer {
|
|
sendMessage(userIdList, message);
|
|
sendMessage(userIdList, message);
|
|
}
|
|
}
|
|
//保存到小区群聊的聊天记录中
|
|
//保存到小区群聊的聊天记录中
|
|
- saveChatLog(0, fromMsgDetail.getToId(), 1, servers.get(session.getId()).getUserId(), fromMsgDetail.getMessage());
|
|
|
|
|
|
+ saveChatLog(0, fromMsgDetail.getToId(), 1, servers.get(session.getId()).getUserId(), fromMsgDetail.getMessage(),editTime);
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
//发送给指定用户
|
|
//发送给指定用户
|
|
@@ -176,7 +181,7 @@ public class WebSocketServer {
|
|
* @param userId
|
|
* @param userId
|
|
* @param content
|
|
* @param content
|
|
*/
|
|
*/
|
|
- private void saveChatLog(int type, Long chatPartnerId,int showRoomFlag,Long userId,String content){
|
|
|
|
|
|
+ private void saveChatLog(int type, Long chatPartnerId,int showRoomFlag,Long userId,String content,Date editDate){
|
|
ChatLogDTO dto = new ChatLogDTO();
|
|
ChatLogDTO dto = new ChatLogDTO();
|
|
ChatLogService chatLogService = applicationContext.getBean(ChatLogService.class);
|
|
ChatLogService chatLogService = applicationContext.getBean(ChatLogService.class);
|
|
dto.setType(type);
|
|
dto.setType(type);
|
|
@@ -184,7 +189,7 @@ public class WebSocketServer {
|
|
dto.setShowRoomFlag(showRoomFlag);
|
|
dto.setShowRoomFlag(showRoomFlag);
|
|
dto.setContent(content);
|
|
dto.setContent(content);
|
|
dto.setEditUser(userId);
|
|
dto.setEditUser(userId);
|
|
- dto.setEditTime(new Date());
|
|
|
|
|
|
+ dto.setEditTime(editDate);
|
|
if(dto.getShowRoomFlag()==null){
|
|
if(dto.getShowRoomFlag()==null){
|
|
dto.setShowRoomFlag(1);
|
|
dto.setShowRoomFlag(1);
|
|
}
|
|
}
|