<?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.imr.mapper.DestructionPublicityMapper">

    <resultMap id="destructionPublicityMap" type="digital.laboratory.platform.imr.entity.DestructionPublicity">
        <id property="id" column="id"/>
        <result property="applicantId" column="applicant_id"/>
        <result property="reviewerId" column="reviewer_id"/>
        <result property="destroyQuantity" column="destroy_quantity"/>
        <result property="destroyCompany" column="destroy_company"/>
        <result property="destroyDate" column="destroy_date"/>
        <result property="remarks" column="remarks"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="ReleaseDate" column="release_date" />
    </resultMap>


    <resultMap id="publicityVO" type="digital.laboratory.platform.imr.vo.DestructionPublicityVO" extends="destructionPublicityMap">
        <result property="applicantName" column="applicant_name"/>
        <result property="reviewerName" column="reviewer_name"/>
    </resultMap>



    <sql id="basePublicityVO">
        select dp.*,
               (
                   SELECT user.name
                   FROM dlp_base.sys_user user
                   WHERE user.user_id=dp.applicant_id
               ) AS applicant_name,
               (
                   SELECT user.name
                   FROM dlp_base.sys_user user
                   WHERE user.user_id=dp.reviewer_id
               ) AS reviewer_name
        from dlp_identification_material_repository.destruction_publicity dp
    </sql>



    <select id="getDestructionPublicityPage" resultMap="publicityVO">
        <include refid="basePublicityVO"/>
        ${ew.customSqlSegment}
    </select>



<!--  获取销毁与公示VO  DestructionPublicityVO getPublicityVO(String id);-->

    <select id="getPublicityVO" resultMap="publicityVO">
        select dp.*,
           (
             SELECT user.name
             FROM dlp_base.sys_user user
             WHERE user.user_id=dp.applicant_id
           ) AS applicant_name,
               (
                   SELECT user.name
                   FROM dlp_base.sys_user user
                   WHERE user.user_id=dp.reviewer_id
               ) AS reviewer_name
        from dlp_identification_material_repository.destruction_publicity dp
        where dp.id = #{id}
    </select>







</mapper>