<?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.ZlrzSynergistMapper">

    <resultMap id="zlrzSynergistMap" type="com.tofly.qualitycontrol.entity.ZlrzSynergist">
        <id property="id" column="ID"/>
        <result property="synergistName" column="SYNERGIST_NAME"/>
        <result property="synergistId" column="SYNERGIST_ID"/>
        <result property="synergistDeptId" column="SYNERGIST_DEPT_ID"/>
        <result property="synergistDeptName" column="SYNERGIST_DEPT_NAME"/>
        <result property="gdId" column="GD_ID"/>
        <result property="synergistType" column="SYNERGIST_TYPE"/>
        <result property="tableName" column="TABLE_NAME"/>
        <result property="delStatus" column="DEL_STATUS"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="updateUser" column="UPDATE_USER"/>
        <result property="updateTime" column="UPDATE_TIME"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
        <association property="updateUserName" column="UPDATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
    </resultMap>

    <select id="getSynergists" resultMap="zlrzSynergistMap">
        SELECT * FROM TF_YWPN_ZLRZ_SYNERGIST_W WHERE SYNERGIST_TYPE = 1 AND TABLE_NAME = 'TF_YWPN_ZLRZ_W' AND
                                                     (GD_ID = #{id}
                                                          <if test="parentId != null">
                                                          OR GD_ID = #{parentId}
                                                          </if>)
    </select>


</mapper>
