Просмотр исходного кода

企微聊天-消息撤回bug修复

Long 2 дней назад
Родитель
Сommit
dc990b3718

+ 1 - 2
fs-service/src/main/java/com/fs/fastGpt/service/impl/AiHookServiceImpl.java

@@ -2681,8 +2681,7 @@ public class AiHookServiceImpl implements AiHookService {
         }
 
         qwMsg.setMsgType(6);
-        qwMsg.setSessionId(null);
-        qwMsgMapper.updateQwMsg(qwMsg);
+        qwMsgMapper.updateQwMsgByMsgIdAndSessionId(qwMsg);
 
         String type = "text";
         MsgType messageType = MsgType.getMsgType(qwMsg.getMsgType());

+ 11 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwMsgMapper.java

@@ -68,4 +68,15 @@ public interface QwMsgMapper  extends BaseMapper<QwMsg>
      */
     @Select("select * from qw_msg where session_id = #{sessionId} and qw_app_info = #{qwAppInfo}")
     QwMsg selectQwMsgBySessionIdAndQwAppInfo(@Param("sessionId") Long sessionId, @Param("qwAppInfo") String qwAppInfo);
+
+    /**
+     * 根据会话ID和消息ID查询消息
+     */
+    @Select("select * from qw_msg where msg_id = #{msgId} and session_id = #{sessionId}")
+    QwMsg selectQwMsgByMsgIdAndSessionId(@Param("msgId") Long msgId, @Param("sessionId") Long sessionId);
+
+    /**
+     * 修改企微聊天记录
+     */
+    int updateQwMsgByMsgIdAndSessionId(QwMsg qwMsg);
 }

+ 2 - 3
fs-service/src/main/java/com/fs/qw/service/impl/QwMsgServiceImpl.java

@@ -456,7 +456,7 @@ public class QwMsgServiceImpl extends ServiceImpl<QwMsgMapper, QwMsg> implements
         }
         // 消息撤销
         else if (MsgType.CANCEL == msgType) {
-            QwMsg qwMsg = qwMsgMapper.selectQwMsgByMsgId(param.getMsgId());
+            QwMsg qwMsg = qwMsgMapper.selectQwMsgByMsgIdAndSessionId(param.getMsgId(), param.getSessionId());
             if (qwMsg == null || qwMsg.getQwMsgId() == null) {
                 return R.error("消息不存在");
             }
@@ -475,8 +475,7 @@ public class QwMsgServiceImpl extends ServiceImpl<QwMsgMapper, QwMsg> implements
             }
 
             qwMsg.setMsgType(6);
-            qwMsg.setSessionId(null);
-            qwMsgMapper.updateQwMsg(qwMsg);
+            qwMsgMapper.updateQwMsgByMsgIdAndSessionId(qwMsg);
 
             // 组装返回消息结构
             QwMessageListVO listVO = new QwMessageListVO();

+ 22 - 0
fs-service/src/main/resources/mapper/qw/QwMsgMapper.xml

@@ -117,6 +117,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where msg_id = #{msgId}
     </update>
 
+    <update id="updateQwMsgByMsgIdAndSessionId">
+        update qw_msg
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
+            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
+            <if test="content != null">content = #{content},</if>
+            <if test="msgType != null">msg_type = #{msgType},</if>
+            <if test="sendType != null">send_type = #{sendType},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="roleId != null">role_id = #{roleId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="msgJson != null">msg_json = #{msgJson},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="nickName != null">nick_name = #{nickName},</if>
+            <if test="avatar != null">avatar = #{avatar},</if>
+            <if test="qwMsgId != null">qw_msg_id = #{qwMsgId},</if>
+            <if test="qwAppInfo != null">qw_app_info = #{qwAppInfo},</if>
+        </trim>
+        where msg_id = #{msgId} and session_id = #{sessionId}
+    </update>
+
     <delete id="deleteQwMsgByMsgId" parameterType="Long">
         delete from qw_msg where msg_id = #{msgId}
     </delete>