update 聊天室误删客服bug修改
This commit is contained in:
parent
7258909381
commit
80b15dcf5b
|
@ -7,6 +7,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -117,6 +118,31 @@ public class RedisService {
|
||||||
return operation.get(key);
|
return operation.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有数字类型转换为BigDecimal
|
||||||
|
* @param key 缓存键值
|
||||||
|
* @return 缓存键值对应数据
|
||||||
|
*/
|
||||||
|
public BigDecimal getCacheBigDecimal(final String key) {
|
||||||
|
ValueOperations<String, Object> operation = redisTemplate.opsForValue();
|
||||||
|
Object value = operation.get(key);
|
||||||
|
if (value != null) {
|
||||||
|
if (value instanceof BigDecimal) {
|
||||||
|
return (BigDecimal) value;
|
||||||
|
} else if (value instanceof String) {
|
||||||
|
try {
|
||||||
|
return new BigDecimal((String) value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 处理字符串无法转换为 BigDecimal 的情况
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (value instanceof Number) {
|
||||||
|
return new BigDecimal(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单个对象
|
* 删除单个对象
|
||||||
*
|
*
|
||||||
|
|
|
@ -48,8 +48,10 @@ public class WebSocketEventListener implements ApplicationListener<SessionDiscon
|
||||||
//游客断开链接,通知客服删除游客聊天室
|
//游客断开链接,通知客服删除游客聊天室
|
||||||
stompService.customerCloseRoom(user.getName());
|
stompService.customerCloseRoom(user.getName());
|
||||||
// 删除数据库中游客数据
|
// 删除数据库中游客数据
|
||||||
int delete = chatRoomMapper.delete(new LambdaUpdateWrapper<ChatRoom>().eq(ChatRoom::getUserOneEmail, user.getName()));
|
int delete = chatRoomMapper.delete(new LambdaUpdateWrapper<ChatRoom>()
|
||||||
int delete1 = chatMessageMapper.delete(new LambdaUpdateWrapper<ChatMessage>().eq(ChatMessage::getSendEmail, user.getName()));
|
.eq(ChatRoom::getUserOneEmail, user.getName()).like(ChatRoom::getUserOneEmail, "guest_"));
|
||||||
|
int delete1 = chatMessageMapper.delete(new LambdaUpdateWrapper<ChatMessage>()
|
||||||
|
.eq(ChatMessage::getSendEmail, user.getName()).like(ChatMessage::getSendEmail, "guest_"));
|
||||||
LOGGER.info("删除游客聊天室个数:{},消息个数{}", delete,delete1);
|
LOGGER.info("删除游客聊天室个数:{},消息个数{}", delete,delete1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ public interface ChatRoomMapper extends BaseMapper<ChatRoom> {
|
||||||
*/
|
*/
|
||||||
ChatRoomDto findRoomByUserEmail(@Param("userEmail") String userEmail);
|
ChatRoomDto findRoomByUserEmail(@Param("userEmail") String userEmail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或修改聊天室
|
||||||
|
* @param room
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insetOrUpdateRoom(@Param("room") ChatRoom room);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,16 +152,7 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
||||||
.userTwoEmail(email)
|
.userTwoEmail(email)
|
||||||
.build();
|
.build();
|
||||||
try{
|
try{
|
||||||
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
int insert = chatRoomMapper.insetOrUpdateRoom(build);
|
||||||
.eq(ChatRoom::getUserOneEmail, userEmail).eq(ChatRoom::getUserTwoEmail, email));
|
|
||||||
if (chatRoom != null){
|
|
||||||
return R.success(ChatRoomDto.builder()
|
|
||||||
.id(chatRoom.getId())
|
|
||||||
.selfEmail(userEmail)
|
|
||||||
.customerIsOnline(customerIsOnline)
|
|
||||||
.userEmail(chatRoom.getUserTwoEmail()).build());
|
|
||||||
}
|
|
||||||
int insert = chatRoomMapper.insert(build);
|
|
||||||
if (insert > 0){
|
if (insert > 0){
|
||||||
return R.success(ChatRoomDto.builder()
|
return R.success(ChatRoomDto.builder()
|
||||||
.id(build.getId())
|
.id(build.getId())
|
||||||
|
|
|
@ -43,4 +43,12 @@
|
||||||
WHERE
|
WHERE
|
||||||
user_one_email = #{userEmail}
|
user_one_email = #{userEmail}
|
||||||
</select>
|
</select>
|
||||||
|
<insert id="insetOrUpdateRoom">
|
||||||
|
INSERT INTO chat_room(user_one_email,user_two_email)
|
||||||
|
VALUES (#{room.userOneEmail},#{room.userTwoEmail})
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
user_one_email = #{room.userOneEmail},
|
||||||
|
user_two_email = #{room.userTwoEmail}
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue