AiSparringTaskStaffRefMapper.xml 7.47 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="cn.com.glsx.dj.mindworkplate.mapper.AiSparringTaskStaffRefMapper" >
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.AiSparringTaskStaffRef" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="task_id" property="taskId" jdbcType="VARCHAR" />
        <result column="yq_merchant_id" property="yqMerchantId" jdbcType="INTEGER" />
        <result column="yq_merchant_name" property="yqMerchantName" jdbcType="VARCHAR" />
        <result column="staff_name" property="staffName" jdbcType="VARCHAR" />
        <result column="staff_uuid" property="staffUuid" jdbcType="VARCHAR" />
        <result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
        <result column="try_count" property="tryCount" jdbcType="INTEGER" />
        <result column="sparring_status" property="sparringStatus" jdbcType="INTEGER" />
        <result column="estimated_result" property="estimatedResult" jdbcType="VARCHAR" />
        <result column="score" property="score" jdbcType="DECIMAL" />
        <result column="completion_time" property="completionTime" jdbcType="TIMESTAMP" />
        <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
        <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
        <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
    </resultMap>
    <resultMap id="DTOResultMap" extends="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskStaffRefDTO" >
    </resultMap>

    <resultMap id="TaskStaffRecordExportMap" type="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskStaffRecordExportDTO">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="staff_name" property="staffName" jdbcType="VARCHAR" />
        <result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
        <result column="role_type" property="roleType" jdbcType="INTEGER" />
        <result column="sparring_duration" property="sparringDuration" jdbcType="INTEGER" />
        <result column="completion_time" property="completionTime" jdbcType="TIMESTAMP" />
        <result column="content" property="content" jdbcType="VARCHAR" />
        <result column="score" property="score" />
        <result column="sparring_type" property="sparringType" />
        <result column="sparring_type" property="sparringType" />
        <result column="level" property="level" jdbcType="VARCHAR" />
    </resultMap>

    <sql id="Prefix_Column">
        ${prefix}.id as ${prefix}_id,
        ${prefix}.task_id as ${prefix}_task_id,
        ${prefix}.yq_merchant_id as ${prefix}_yq_merchant_id,
        ${prefix}.yq_merchant_name as ${prefix}_yq_merchant_name,
        ${prefix}.staff_name as ${prefix}_staff_name,
        ${prefix}.staff_uuid as ${prefix}_staff_uuid,
        ${prefix}.staff_phone as ${prefix}_staff_phone,
        ${prefix}.try_count as ${prefix}_try_count,
        ${prefix}.sparring_status as ${prefix}_sparring_status,
        ${prefix}.estimated_result as ${prefix}_estimated_result,
        ${prefix}.score as ${prefix}_score,
        ${prefix}.completion_time as ${prefix}_completion_time,
        ${prefix}.created_by as ${prefix}_created_by,
        ${prefix}.created_date as ${prefix}_created_date,
        ${prefix}.updated_by as ${prefix}_updated_by,
        ${prefix}.updated_date as ${prefix}_updated_date,
        ${prefix}.deleted_flag as ${prefix}_deleted_flag
    </sql>

    <select id="page"
            parameterType="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskStaffRequestDTO"
            resultMap="DTOResultMap">
        select * from ai_sparring_task_staff_ref astsr
        <where>
            astsr.deleted_flag = 'N'
            <if test="id != null">
                and astsr.id = #{id}
            </if>
            <if test="taskId != null">
                and astsr.task_id = #{taskId}
            </if>
            <if test="yqMerchantId != null">
                and astsr.yq_merchant_id = #{yqMerchantId}
            </if>
            <if test="yqMerchantName != null and yqMerchantName != ''">
                and astsr.yq_merchant_name like concat('%', #{yqMerchantName}, '%')
            </if>
            <if test="staffPhone != null and staffPhone != ''">
                and astsr.staff_phone like concat('%', #{staffPhone}, '%')
            </if>
            <if test="staffName != null and staffName != ''">
                and astsr.staff_name like concat('%', #{staffName}, '%')
            </if>
            <if test="sparringStatus != null">
                and astsr.sparring_status = #{sparringStatus}
            </if>
            <if test="startTime != null">
                and astsr.completion_time &gt;= #{startTime}
            </if>
            <if test="endTime != null">
                and astsr.completion_time &lt;= #{endTime}
            </if>
        </where>
        order by astsr.created_date desc
    </select>

    <select id="findByIds" resultMap="BaseResultMap">
        select * from ai_sparring_task_staff_ref
        <where>
            deleted_flag = 'N' and id in
            <foreach collection="ids" item="id" close=")" open="(" separator=",">
                #{id}
            </foreach>
        </where>
    </select>

    <select id="findById" resultMap="DTOResultMap">
        select * from ai_sparring_task_staff_ref
        where deleted_flag = 'N' and id = #{id}
    </select>

    <select id="findByStaffUuid" resultMap="DTOResultMap">
        select * from ai_sparring_task_staff_ref
        where deleted_flag = 'N' and staff_uuid = #{staffUuid}
        order by try_count, created_date desc
        limit 1
    </select>

    <update id="incrTryCount">
        update ai_sparring_task_staff_ref set try_count = try_count + 1, updated_date = current_timestamp()
        where deleted_flag = 'N' and id = #{id} and try_count &lt; 3
    </update>

    <select id="listTaskStaffRecord" parameterType="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskStaffRequestDTO"
            resultMap="TaskStaffRecordExportMap">
        select ssr.id, ssr.sparring_duration, ssr.completion_time, ssr.role_type, ssr.score,assi.staff_name, assi.staff_phone,
        ssr.sparring_type, ssr.`level`
        from ai_sparring_staff_record ssr
        left join ai_sparring_staff_info assi on ssr.task_staff_id = assi.id and assi.deleted_flag = 'N'
        <where>
            ssr.deleted_flag = 'N'
            <if test="sparringStatus != null">
                and ssr.sparring_status = #{sparringStatus}
            </if>
            <if test="taskId != null">
                and ssr.sparring_task_id = #{taskId}
            </if>
            <if test="staffPhone != null and staffPhone != ''">
                and assi.staff_phone like concat('%', #{staffPhone}, '%')
            </if>
            <if test="staffName != null and staffName != ''">
                and assi.staff_name like concat('%', #{staffName}, '%')
            </if>
            <if test="startTime != null">
                and ssr.completion_time &gt;= #{startTime}
            </if>
            <if test="endTime != null">
                and ssr.completion_time &lt;= #{endTime}
            </if>
        </where>
        order by ssr.completion_time desc
    </select>
</mapper>