<?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.tofly.qualitycontrol.mapper.MassauditMapper">

    <resultMap id="massauditMap" type="com.tofly.qualitycontrol.entity.Massaudit">
        <id property="id" column="ID"/>
        <result property="num" column="NUM"/>
        <result property="code" column="CODE"/>
        <result property="process" column="PROCESS"/>
        <result property="auditState" column="AUDIT_STATE"/>
        <result property="initiator" column="INITIATOR"/>
        <result property="auditUser" column="AUDIT_USER"/>
        <result property="msg" column="MSG"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="fileIds" column="FILE_IDS"/>
        <result property="parentId" column="PARENT_ID"/>
        <result property="auditDept" column="AUDIT_DEPT"/>
        <association property="initiatorName" column="INITIATOR"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="auditUserName" column="AUDIT_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="auditDeptName" column="AUDIT_DEPT"
                     select="getDeptName"/>
        <association property="processName" column="PROCESS"
                     select="getProcessName"/>
        <association property="auditStateName" column="AUDIT_STATE"
                     select="getStateName"/>
    </resultMap>

    <select id="getDeptName" resultType="string">
        select NAME
        from TF_SMPN_DEPARTMENT_X
        where id = #{id}
    </select>

    <select id="getStateName" resultType="string">
        select decode(#{id}, 0, '未审核', 1, '驳回', 2, '通过', '')
        from DUAL
    </select>

    <select id="getProcessName" resultType="string">
        select decode(#{id}, 0, '整改下达', 1, '整改审核', '')
        from DUAL
    </select>


</mapper>
