<?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="digital.laboratory.platform.entrustment.mapper.EntrustApproveRecordMapper">

    <resultMap id="BaseResultMap" type="digital.laboratory.platform.entrustment.entity.EntrustApproveRecord">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="entrustId" column="entrust_id" jdbcType="VARCHAR"/>
            <result property="approveType" column="approve_type" jdbcType="TINYINT"/>
            <result property="comments" column="comments" jdbcType="VARCHAR"/>
            <result property="userId" column="user_id" jdbcType="VARCHAR"/>
            <result property="orgId" column="org_id" jdbcType="VARCHAR"/>
            <result property="approveTime" column="approve_time" jdbcType="TIMESTAMP"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        ear.id,
        ear.entrust_id,
        ear.approve_type,
        ear.comments,
        ear.user_id,
        ear.org_id,
        ear.approve_time,
        ear.create_time,
        ear.create_by,
        ear.update_time,
        ear.update_by
    </sql>

    <sql id="EntrustApproveRecordVOSQL">
        SELECT
            <include refid="Base_Column_List"></include>,
            c.case_name,
            e.client_org_name,
            e.entrustment_type
        FROM b_entrust_approve_record ear
            LEFT JOIN b_entrustment e ON e.id = ear.entrust_id
            LEFT JOIN b_case_event c on e.case_id = c.id
    </sql>

    <select id="voPage" resultType="digital.laboratory.platform.entrustment.vo.EntrustApproveRecordVO">
        <include refid="EntrustApproveRecordVOSQL"></include>
        ${ew.customSqlSegment}
    </select>
</mapper>
