<?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.hzya.frame.mdm.mdmModuleDistributeDetail.dao.impl.MdmModuleDistributeDetailDaoImpl">

    <resultMap id="get-MdmModuleDistributeDetailEntity-result" type="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
       <result property="id" column="id" jdbcType="VARCHAR"/>
           <result property="mdmId" column="mdm_id" jdbcType="VARCHAR"/>
           <result property="distributeId" column="distribute_id" jdbcType="VARCHAR"/>
           <result property="apiId" column="api_id" jdbcType="VARCHAR"/>
           <result property="sourceField" column="source_field" jdbcType="VARCHAR"/>
           <result property="sourceName" column="source_name" jdbcType="VARCHAR"/>
           <result property="targetField" column="target_field" jdbcType="VARCHAR"/>
           <result property="targetName" column="target_name" jdbcType="VARCHAR"/>
           <result property="defaultVaule" column="default_vaule" jdbcType="VARCHAR"/>
           <result property="sourceFieldPath" column="source_field_path" jdbcType="VARCHAR"/>
           <result property="targetFieldPath" column="target_field_path" jdbcType="VARCHAR"/>
           <result property="targetPath" column="target_path" jdbcType="VARCHAR"/>
           <result property="sourcePath" column="source_path" jdbcType="VARCHAR"/>
           <result property="sorts" column="sorts" jdbcType="INTEGER"/>
           <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
           <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
           <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
           <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
           <result property="sts" column="sts" jdbcType="VARCHAR"/>
           <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
           <result property="coordinate" column="coordinate" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "MdmModuleDistributeDetailEntity_Base_Column_List">
        id
       ,mdm_id 
        ,distribute_id 
        ,api_id 
        ,source_field 
        ,source_name 
        ,target_field 
        ,target_name 
        ,default_vaule 
        ,source_field_path 
        ,target_field_path 
        ,target_path 
        ,source_path 
        ,sorts 
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
        ,coordinate 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
    select
    <include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
    from mdm_module_distribute_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
            <if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
            <if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
            <if test="sourceField != null and sourceField != ''"> and source_field = #{sourceField} </if>
            <if test="sourceName != null and sourceName != ''"> and source_name = #{sourceName} </if>
            <if test="targetField != null and targetField != ''"> and target_field = #{targetField} </if>
            <if test="targetName != null and targetName != ''"> and target_name = #{targetName} </if>
            <if test="defaultVaule != null and defaultVaule != ''"> and default_vaule = #{defaultVaule} </if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> and source_field_path = #{sourceFieldPath} </if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> and target_field_path = #{targetFieldPath} </if>
            <if test="targetPath != null and targetPath != ''"> and target_path = #{targetPath} </if>
            <if test="sourcePath != null and sourcePath != ''"> and source_path = #{sourcePath} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
            <if test="create_time != null"> and create_time = #{create_time} </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
            <if test="modify_time != null"> and modify_time = #{modify_time} </if>
            <if test="sts != null and sts != ''"> and sts = #{sts} </if>
            <if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
            <if test="coordinate != null and coordinate != ''"> and coordinate = #{coordinate} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
        select  count(1)   from mdm_module_distribute_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
            <if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
            <if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
            <if test="sourceField != null and sourceField != ''"> and source_field = #{sourceField} </if>
            <if test="sourceName != null and sourceName != ''"> and source_name = #{sourceName} </if>
            <if test="targetField != null and targetField != ''"> and target_field = #{targetField} </if>
            <if test="targetName != null and targetName != ''"> and target_name = #{targetName} </if>
            <if test="defaultVaule != null and defaultVaule != ''"> and default_vaule = #{defaultVaule} </if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> and source_field_path = #{sourceFieldPath} </if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> and target_field_path = #{targetFieldPath} </if>
            <if test="targetPath != null and targetPath != ''"> and target_path = #{targetPath} </if>
            <if test="sourcePath != null and sourcePath != ''"> and source_path = #{sourcePath} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
            <if test="create_time != null"> and create_time = #{create_time} </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
            <if test="modify_time != null"> and modify_time = #{modify_time} </if>
            <if test="sts != null and sts != ''"> and sts = #{sts} </if>
            <if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
            <if test="coordinate != null and coordinate != ''"> and coordinate = #{coordinate} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
    select
    <include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
    from mdm_module_distribute_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
            <if test="mdmId != null and mdmId != ''"> and mdm_id like concat('%',#{mdmId},'%') </if>
            <if test="distributeId != null and distributeId != ''"> and distribute_id like concat('%',#{distributeId},'%') </if>
            <if test="apiId != null and apiId != ''"> and api_id like concat('%',#{apiId},'%') </if>
            <if test="sourceField != null and sourceField != ''"> and source_field like concat('%',#{sourceField},'%') </if>
            <if test="sourceName != null and sourceName != ''"> and source_name like concat('%',#{sourceName},'%') </if>
            <if test="targetField != null and targetField != ''"> and target_field like concat('%',#{targetField},'%') </if>
            <if test="targetName != null and targetName != ''"> and target_name like concat('%',#{targetName},'%') </if>
            <if test="defaultVaule != null and defaultVaule != ''"> and default_vaule like concat('%',#{defaultVaule},'%') </if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> and source_field_path like concat('%',#{sourceFieldPath},'%') </if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> and target_field_path like concat('%',#{targetFieldPath},'%') </if>
            <if test="targetPath != null and targetPath != ''"> and target_path like concat('%',#{targetPath},'%') </if>
            <if test="sourcePath != null and sourcePath != ''"> and source_path like concat('%',#{sourcePath},'%') </if>
            <if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
            <if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
            <if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
            <if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
            <if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
            <if test="coordinate != null and coordinate != ''"> and coordinate like concat('%',#{coordinate},'%') </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="MdmModuleDistributeDetailentity_list_or" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
    select
    <include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
    from mdm_module_distribute_detail
    <trim prefix="where" prefixOverrides="and"> 
         <if test="id != null and id != ''"> or id = #{id} </if>
             <if test="mdmId != null and mdmId != ''"> or mdm_id = #{mdmId} </if>
             <if test="distributeId != null and distributeId != ''"> or distribute_id = #{distributeId} </if>
             <if test="apiId != null and apiId != ''"> or api_id = #{apiId} </if>
             <if test="sourceField != null and sourceField != ''"> or source_field = #{sourceField} </if>
             <if test="sourceName != null and sourceName != ''"> or source_name = #{sourceName} </if>
             <if test="targetField != null and targetField != ''"> or target_field = #{targetField} </if>
             <if test="targetName != null and targetName != ''"> or target_name = #{targetName} </if>
             <if test="defaultVaule != null and defaultVaule != ''"> or default_vaule = #{defaultVaule} </if>
             <if test="sourceFieldPath != null and sourceFieldPath != ''"> or source_field_path = #{sourceFieldPath} </if>
             <if test="targetFieldPath != null and targetFieldPath != ''"> or target_field_path = #{targetFieldPath} </if>
             <if test="targetPath != null and targetPath != ''"> or target_path = #{targetPath} </if>
             <if test="sourcePath != null and sourcePath != ''"> or source_path = #{sourcePath} </if>
             <if test="sorts != null"> or sorts = #{sorts} </if>
             <if test="create_user_id != null and create_user_id != ''"> or create_user_id = #{create_user_id} </if>
              <if test="create_time != null"> or create_time = #{create_time} </if>
              <if test="modify_user_id != null and modify_user_id != ''"> or modify_user_id = #{modify_user_id} </if>
              <if test="modify_time != null"> or modify_time = #{modify_time} </if>
              <if test="sts != null and sts != ''"> or sts = #{sts} </if>
             <if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
              <if test="coordinate != null and coordinate != ''"> or coordinate = #{coordinate} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString()  "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
    insert into mdm_module_distribute_detail(
  <trim suffix="" suffixOverrides=",">
       <if test="id != null and id != ''"> id , </if>
            <if test="mdmId != null and mdmId != ''"> mdm_id , </if>
            <if test="distributeId != null and distributeId != ''"> distribute_id , </if>
            <if test="apiId != null and apiId != ''"> api_id , </if>
            <if test="sourceField != null and sourceField != ''"> source_field , </if>
            <if test="sourceName != null and sourceName != ''"> source_name , </if>
            <if test="targetField != null and targetField != ''"> target_field , </if>
            <if test="targetName != null and targetName != ''"> target_name , </if>
            <if test="defaultVaule != null and defaultVaule != ''"> default_vaule , </if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> source_field_path , </if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> target_field_path , </if>
            <if test="targetPath != null and targetPath != ''"> target_path , </if>
            <if test="sourcePath != null and sourcePath != ''"> source_path , </if>
            <if test="sorts != null"> sorts , </if>
            <if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
            <if test="create_time != null"> create_time , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
            <if test="modify_time != null"> modify_time , </if>
            <if test="sts != null and sts != ''"> sts , </if>
            <if test="org_id != null and org_id != ''"> org_id , </if>
            <if test="coordinate != null and coordinate != ''"> coordinate , </if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="id != null and id != ''"> #{id} ,</if>
            <if test="mdmId != null and mdmId != ''"> #{mdmId} ,</if>
            <if test="distributeId != null and distributeId != ''"> #{distributeId} ,</if>
            <if test="apiId != null and apiId != ''"> #{apiId} ,</if>
            <if test="sourceField != null and sourceField != ''"> #{sourceField} ,</if>
            <if test="sourceName != null and sourceName != ''"> #{sourceName} ,</if>
            <if test="targetField != null and targetField != ''"> #{targetField} ,</if>
            <if test="targetName != null and targetName != ''"> #{targetName} ,</if>
            <if test="defaultVaule != null and defaultVaule != ''"> #{defaultVaule} ,</if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> #{sourceFieldPath} ,</if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> #{targetFieldPath} ,</if>
            <if test="targetPath != null and targetPath != ''"> #{targetPath} ,</if>
            <if test="sourcePath != null and sourcePath != ''"> #{sourcePath} ,</if>
            <if test="sorts != null"> #{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
            <if test="create_time != null"> #{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
            <if test="modify_time != null"> #{modify_time} ,</if>
            <if test="sts != null and sts != ''"> #{sts} ,</if>
            <if test="org_id != null and org_id != ''"> #{org_id} ,</if>
            <if test="coordinate != null and coordinate != ''"> #{coordinate} ,</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" >
  insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, source_field, source_name, target_field, target_name, default_vaule, source_field_path, target_field_path, target_path, source_path, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, coordinate,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.sourceField},#{entity.sourceName},#{entity.targetField},#{entity.targetName},#{entity.defaultVaule},#{entity.sourceFieldPath},#{entity.targetFieldPath},#{entity.targetPath},#{entity.sourcePath},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.coordinate}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" >
    insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, source_field, source_name, target_field, target_name, default_vaule, source_field_path, target_field_path, target_path, source_path, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, coordinate)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.sourceField},#{entity.sourceName},#{entity.targetField},#{entity.targetName},#{entity.defaultVaule},#{entity.sourceFieldPath},#{entity.targetFieldPath},#{entity.targetPath},#{entity.sourcePath},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.coordinate})
    </foreach>
    on duplicate key update
    mdm_id = values(mdm_id),
    distribute_id = values(distribute_id),
    api_id = values(api_id),
    source_field = values(source_field),
    source_name = values(source_name),
    target_field = values(target_field),
    target_name = values(target_name),
    default_vaule = values(default_vaule),
    source_field_path = values(source_field_path),
    target_field_path = values(target_field_path),
    target_path = values(target_path),
    source_path = values(source_path),
    sorts = values(sorts),
    create_user_id = values(create_user_id),
    create_time = values(create_time),
    modify_user_id = values(modify_user_id),
    modify_time = values(modify_time),
    sts = values(sts),
    org_id = values(org_id),
    coordinate = values(coordinate)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
update mdm_module_distribute_detail  set
<trim suffix="" suffixOverrides=",">
  <if test="mdmId != null and mdmId != ''"> mdm_id = #{mdmId},</if>
  <if test="distributeId != null and distributeId != ''"> distribute_id = #{distributeId},</if>
  <if test="apiId != null and apiId != ''"> api_id = #{apiId},</if>
  <if test="sourceField != null and sourceField != ''"> source_field = #{sourceField},</if>
  <if test="sourceName != null and sourceName != ''"> source_name = #{sourceName},</if>
  <if test="targetField != null and targetField != ''"> target_field = #{targetField},</if>
  <if test="targetName != null and targetName != ''"> target_name = #{targetName},</if>
  <if test="defaultVaule != null and defaultVaule != ''"> default_vaule = #{defaultVaule},</if>
  <if test="sourceFieldPath != null and sourceFieldPath != ''"> source_field_path = #{sourceFieldPath},</if>
  <if test="targetFieldPath != null and targetFieldPath != ''"> target_field_path = #{targetFieldPath},</if>
  <if test="targetPath != null and targetPath != ''"> target_path = #{targetPath},</if>
  <if test="sourcePath != null and sourcePath != ''"> source_path = #{sourcePath},</if>
  <if test="sorts != null"> sorts = #{sorts},</if>
  <if test="create_user_id != null and create_user_id != ''"> create_user_id = #{create_user_id},</if>
    <if test="create_time != null"> create_time = #{create_time},</if>
    <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id = #{modify_user_id},</if>
    <if test="modify_time != null"> modify_time = #{modify_time},</if>
    <if test="sts != null and sts != ''"> sts = #{sts},</if>
  <if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
    <if test="coordinate != null and coordinate != ''"> coordinate = #{coordinate},</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
update mdm_module_distribute_detail  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
update mdm_module_distribute_detail  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
            <if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
            <if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
            <if test="sourceField != null and sourceField != ''"> and source_field = #{sourceField} </if>
            <if test="sourceName != null and sourceName != ''"> and source_name = #{sourceName} </if>
            <if test="targetField != null and targetField != ''"> and target_field = #{targetField} </if>
            <if test="targetName != null and targetName != ''"> and target_name = #{targetName} </if>
            <if test="defaultVaule != null and defaultVaule != ''"> and default_vaule = #{defaultVaule} </if>
            <if test="sourceFieldPath != null and sourceFieldPath != ''"> and source_field_path = #{sourceFieldPath} </if>
            <if test="targetFieldPath != null and targetFieldPath != ''"> and target_field_path = #{targetFieldPath} </if>
            <if test="targetPath != null and targetPath != ''"> and target_path = #{targetPath} </if>
            <if test="sourcePath != null and sourcePath != ''"> and source_path = #{sourcePath} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
                                                                <if test="sts != null and sts != ''"> and sts = #{sts} </if>
                         <if test="coordinate != null and coordinate != ''"> and coordinate = #{coordinate} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from mdm_module_distribute_detail where id = #{id}
</delete>

</mapper>

