1.记录微信消息

2.重复上线问题解决
This commit is contained in:
zhongzb
2023-05-20 12:56:56 +08:00
parent a35e72ad46
commit fe1bd80082
19 changed files with 194 additions and 23 deletions

View File

@@ -0,0 +1,20 @@
package com.abin.mallchat.common.chat.dao;
import com.abin.mallchat.common.chat.domain.entity.WxMsg;
import com.abin.mallchat.common.chat.mapper.WxMsgMapper;
import com.abin.mallchat.common.chat.service.IWxMsgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 微信消息表 服务实现类
* </p>
*
* @author <a href="https://github.com/zongzibinbin">abin</a>
* @since 2023-05-16
*/
@Service
public class WxMsgDao extends ServiceImpl<WxMsgMapper, WxMsg> {
}

View File

@@ -0,0 +1,60 @@
package com.abin.mallchat.common.chat.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 微信消息表
* </p>
*
* @author <a href="https://github.com/zongzibinbin">abin</a>
* @since 2023-05-16
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("wx_msg")
public class WxMsg implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 微信openid用户标识
*/
@TableField("open_id")
private String openId;
/**
* 用户消息
*/
@TableField("msg")
private String msg;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 修改时间
*/
@TableField("update_time")
private Date updateTime;
}

View File

@@ -0,0 +1,16 @@
package com.abin.mallchat.common.chat.mapper;
import com.abin.mallchat.common.chat.domain.entity.WxMsg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 微信消息表 Mapper 接口
* </p>
*
* @author <a href="https://github.com/zongzibinbin">abin</a>
* @since 2023-05-16
*/
public interface WxMsgMapper extends BaseMapper<WxMsg> {
}

View File

@@ -0,0 +1,16 @@
package com.abin.mallchat.common.chat.service;
import com.abin.mallchat.common.chat.domain.entity.WxMsg;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 微信消息表 服务类
* </p>
*
* @author <a href="https://github.com/zongzibinbin">abin</a>
* @since 2023-05-16
*/
public interface IWxMsgService extends IService<WxMsg> {
}

View File

@@ -754,6 +754,9 @@ public class RedisUtils {
public static Boolean zAdd(String key, Object value, double score) {
return zAdd(key, value.toString(), score);
}
public static Boolean zIsMember(String key, Object value) {
return Objects.nonNull(stringRedisTemplate.opsForZSet().score(key,value.toString()));
}
/**
* @param key

View File

@@ -53,6 +53,11 @@ public class UserCache {
RedisUtils.zAdd(onlineKey, uid, optTime.getTime());
}
public boolean isOnline(Long uid) {
String onlineKey = RedisKey.getKey(RedisKey.ONLINE_UID_ZET);
return RedisUtils.zIsMember(onlineKey, uid);
}
//用户下线
public void offline(Long uid, Date optTime) {
String onlineKey = RedisKey.getKey(RedisKey.ONLINE_UID_ZET);

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.abin.mallchat.common.chat.mapper.WxMsgMapper">
</mapper>