Bläddra i källkod

微信会话内容存储开发

anderx 6 månader sedan
förälder
incheckning
623c5a9710

+ 1 - 1
src/main/java/com/kede/common/dao/ChatMsgMapper.java

@@ -10,7 +10,7 @@ import java.util.List;
  * 微信会话存储(ChatMsg)表数据库访问层
  *
  * @author makejava
- * @since 2025-06-17 11:06:18
+ * @since 2025-06-17 15:13:31
  */
 public interface ChatMsgMapper {
 

+ 27 - 28
src/main/java/com/kede/common/mapper/ChatMsgMapper.xml

@@ -5,8 +5,8 @@
     <resultMap type="com.kede.common.model.ChatMsg" id="ChatMsgMap">
         <result property="id" column="id" jdbcType="INTEGER"/>
         <result property="msgid" column="msgid" jdbcType="VARCHAR"/>
-        <result property="action" column="action" jdbcType="VARCHAR"/>
-        <result property="from" column="from" jdbcType="VARCHAR"/>
+        <result property="actionType" column="action_type" jdbcType="VARCHAR"/>
+        <result property="fromId" column="from_id" jdbcType="VARCHAR"/>
         <result property="fromName" column="from_name" jdbcType="VARCHAR"/>
         <result property="tolist" column="tolist" jdbcType="VARCHAR"/>
         <result property="tolistName" column="tolist_name" jdbcType="VARCHAR"/>
@@ -18,7 +18,7 @@
     </resultMap>
 
     <sql id="ChatMsgAllSql">
-        id, msgid, `action`, `from`, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content, create_time
+        id, msgid, action_type, from_id, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content, create_time
     </sql>
 
     <!--查询单个-->
@@ -31,36 +31,36 @@
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
-        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
-                             create_time)
-        values (#{msgid}, #{action}, #{from}, #{fromName}, #{tolist}, #{tolistName}, #{roomid}, #{msgtime}, #{msgtype},
-                #{content}, #{createTime})
+        insert into chat_msg(msgid, action_type, from_id, from_name, tolist, tolist_name, roomid, msgtime, msgtype,
+                             content, create_time)
+        values (#{msgid}, #{actionType}, #{fromId}, #{fromName}, #{tolist}, #{tolistName}, #{roomid}, #{msgtime},
+                #{msgtype}, #{content}, #{createTime})
     </insert>
 
     <insert id="insertBatch">
-        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
-        create_time)
+        insert into chat_msg(msgid, action_type, from_id, from_name, tolist, tolist_name, roomid, msgtime, msgtype,
+        content, create_time)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
+            (#{entity.msgid}, #{entity.actionType}, #{entity.fromId}, #{entity.fromName}, #{entity.tolist},
             #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
             #{entity.createTime})
         </foreach>
     </insert>
 
     <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
-        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
-        create_time)
+        insert into chat_msg(msgid, action_type, from_id, from_name, tolist, tolist_name, roomid, msgtime, msgtype,
+        content, create_time)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
+            (#{entity.msgid}, #{entity.actionType}, #{entity.fromId}, #{entity.fromName}, #{entity.tolist},
             #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
             #{entity.createTime})
         </foreach>
         on duplicate key update
         msgid = values(msgid),
-        action = values(action),
-        from = values(from),
+        action_type = values(action_type),
+        from_id = values(from_id),
         from_name = values(from_name),
         tolist = values(tolist),
         tolist_name = values(tolist_name),
@@ -78,11 +78,11 @@
             <if test="msgid != null and msgid != ''">
                 msgid = #{msgid},
             </if>
-            <if test="action != null and action != ''">
-                action = #{action},
+            <if test="actionType != null and actionType != ''">
+                action_type = #{actionType},
             </if>
-            <if test="from != null and from != ''">
-                from = #{from},
+            <if test="fromId != null and fromId != ''">
+                from_id = #{fromId},
             </if>
             <if test="fromName != null and fromName != ''">
                 from_name = #{fromName},
@@ -125,11 +125,11 @@
             <if test="msgid != null and msgid != ''">
                 and msgid = #{msgid}
             </if>
-            <if test="action != null and action != ''">
-                and action = #{action}
+            <if test="actionType != null and actionType != ''">
+                and action_type = #{actionType}
             </if>
-            <if test="from != null and from != ''">
-                and from = #{from}
+            <if test="fromId != null and fromId != ''">
+                and from_id = #{fromId}
             </if>
             <if test="fromName != null and fromName != ''">
                 and from_name = #{fromName}
@@ -172,11 +172,11 @@
             <if test="msgid != null and msgid != ''">
                 and msgid = #{msgid}
             </if>
-            <if test="action != null and action != ''">
-                and action = #{action}
+            <if test="actionType != null and actionType != ''">
+                and action_type = #{actionType}
             </if>
-            <if test="from != null and from != ''">
-                and from = #{from}
+            <if test="fromId != null and fromId != ''">
+                and from_id = #{fromId}
             </if>
             <if test="fromName != null and fromName != ''">
                 and from_name = #{fromName}
@@ -205,7 +205,6 @@
         </where>
     </select>
 
-
     <!--通过主键删除-->
     <delete id="deleteById">
         delete

+ 12 - 12
src/main/java/com/kede/common/model/ChatMsg.java

@@ -8,10 +8,10 @@ import java.io.Serializable;
  * 微信会话存储(ChatMsg)实体类
  *
  * @author makejava
- * @since 2025-06-17 11:12:22
+ * @since 2025-06-17 15:13:31
  */
 public class ChatMsg implements Serializable {
-    private static final long serialVersionUID = 334641604843861859L;
+    private static final long serialVersionUID = 610390202522406024L;
 
     private Integer id;
     /**
@@ -21,11 +21,11 @@ public class ChatMsg implements Serializable {
     /**
      * 消息动作,目前有send(发送消息)/recall(撤回消息)/switch(切换企业日志)三种类型
      */
-    private String action;
+    private String actionType;
     /**
      * 消息发送方id。同一企业内容为userid,非相同企业为external_userid。消息如果是机器人发出,也为external_userid。
      */
-    private String from;
+    private String fromId;
     /**
      * 发送名称
      */
@@ -76,20 +76,20 @@ public class ChatMsg implements Serializable {
         this.msgid = msgid;
     }
 
-    public String getAction() {
-        return action;
+    public String getActionType() {
+        return actionType;
     }
 
-    public void setAction(String action) {
-        this.action = action;
+    public void setActionType(String actionType) {
+        this.actionType = actionType;
     }
 
-    public String getFrom() {
-        return from;
+    public String getFromId() {
+        return fromId;
     }
 
-    public void setFrom(String from) {
-        this.from = from;
+    public void setFromId(String fromId) {
+        this.fromId = fromId;
     }
 
     public String getFromName() {