WeGroupSopChatMapper.xml 1.57 KB
<?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.linkwechat.wecom.mapper.WeGroupSopChatMapper">

    <resultMap type="WeCommunityTaskEmplVo" id="WeEmplVoResult">
        <result property="userId" column="user_id"/>
        <result property="name" column="user_name"/>
        <result property="avatar" column="head_image_url"/>
        <result property="isDone" column="is_done"/>
    </resultMap>


    <select id="getScopeListByRuleId" parameterType="Long" resultMap="WeEmplVoResult">
        SELECT
            wu.user_id,
            wu.user_name,
            wu.head_image_url,
            wgsc.is_done
        FROM
            we_group_sop_chat wgsc
                LEFT JOIN we_group_sop wgs ON wgsc.rule_id = wgs.rule_id
                LEFT JOIN we_group wg ON wg.chat_id = wgsc.chat_id
                LEFT JOIN we_user wu ON wu.user_id = wg.`owner`
        WHERE
            wgsc.rule_id = #{ruleId}
    </select>


    <insert id="batchBindsSopChat">
        insert into we_group_sop_chat(rule_id, chat_id, is_done) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.ruleId},#{item.chatId}, #{item.isDone})
        </foreach>
    </insert>

    <update id="updateChatSopStatus">
        update we_group_sop_chat wgsc
        inner join we_group wg on wgsc.chat_id = wg.chat_id
        set wgsc.is_done = TRUE
        where wgsc.rule_id = #{ruleId}
          and wg.owner = #{emplId}
    </update>
</mapper>