<?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.sysnew.comparison.controlsLog.dao.impl.ControlsLogDaoImpl">
    <resultMap id="get-ComparisonEntity-result" type="com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity" >
        <result property="id" column="id" 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="companyId" column="company_id" jdbcType="VARCHAR"/>
        <result property="formmainId" column="formmain_id" jdbcType="VARCHAR"/>
        <result property="sourceName" column="source_name" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="sourceData" column="source_data" jdbcType="VARCHAR"/>
        <result property="optionType" column="option_type" jdbcType="VARCHAR"/>
        <result property="optionName" column="option_name" jdbcType="VARCHAR"/>
        <result property="dataType" column="data_type" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
    </resultMap>

    <!--分页查询数据-->
    <select id="list_base" resultMap="get-ComparisonEntity-result"
            parameterType = "com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity">
       select * from ${dbName}
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="formmainId != null and formmainId != ''">and formmain_id = #{formmainId}</if>
            <if test="code != null and code != ''">and code = #{code}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceData != null and sourceData != ''">and source_data = #{sourceData}</if>
            <if test="optionType != null and optionType != ''">and option_type = #{optionType}</if>
            <if test="optionName != null and optionName != ''">and option_name = #{optionName}</if>
            <if test="dataType != null and dataType != ''">and data_type = #{dataType}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</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>
           and sts='Y'
        </trim>
    </select>




  <!--新增档案数据-->
    <insert id="saveControlsLog" parameterType = "com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity">
        insert into ${dbName}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="formmainId != null and formmainId != ''">formmain_id,</if>
            <if test="code != null and code != ''">code ,</if>
            <if test="sourceName != null and sourceName != ''">source_name ,</if>
            <if test="sourceData != null and sourceData != ''">source_data ,</if>
            <if test="optionType != null and optionType != ''">option_type ,</if>
            <if test="optionName != null and optionName != ''">option_name ,</if>
            <if test="dataType != null and dataType != ''"> data_type,</if>
            <if test="remark != null and remark != ''"> remark,</if>
            <if test="sorts != null"> sorts,</if>
            <if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
            <if test="org_id != null and org_id != ''"> org_id , </if>
            <if test="companyId != null and companyId != ''"> company_id , </if>
            create_time,
            modify_time,
            sts
        </trim>
          values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="formmainId != null and formmainId != ''">#{formmainId},</if>
            <if test="code != null and code != ''">#{code} ,</if>
            <if test="sourceName != null and sourceName != ''">#{sourceName} ,</if>
            <if test="sourceData != null and sourceData != ''">#{sourceData} ,</if>
            <if test="optionType != null and optionType != ''">#{optionType} ,</if>
            <if test="optionName != null and optionName != ''">#{optionName} ,</if>
            <if test="dataType != null and dataType != ''"> #{dataType},</if>
            <if test="remark != null and remark != ''"> #{remark},</if>
            <if test="sorts != null"> #{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
            <if test="org_id != null and org_id != ''"> #{org_id} ,</if>
            <if test="companyId != null and companyId != ''"> #{companyId} ,</if>
            <if test="create_time != null"> #{create_time} ,</if>
            <if test="create_time == null">now() ,</if>
            <if test="modify_time != null"> #{modify_time} ,</if>
            <if test="modify_time == null"> now() ,</if>
            <if test="sts != null and sts != ''"> #{sts} ,</if>
            <if test="sts == null ">'Y'</if>
        </trim>
    </insert>

    <!--通过主键修改方法-->
    <update id="entity_update" parameterType = "com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity" >
        update ${dbName} set
        <trim suffix="" suffixOverrides=",">
            <if test="formmainId != null and formmainId != ''"> formmain_id = #{formmainId},</if>
            <if test="sourceName != null and sourceName != ''"> source_name = #{sourceName},</if>
            <if test="code != null and code != ''"> code = #{code},</if>
            <if test="sourceData != null and sourceData != ''"> source_data = #{sourceData},</if>
            <if test="optionType != null and optionType != ''"> option_type = #{optionType},</if>
            <if test="optionName != null and optionName != ''"> option_name = #{optionName},</if>
            <if test="dataType != null and dataType != ''"> data_type = #{dataType},</if>
            <if test="remark != null and remark != ''"> remark = #{remark},</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="modify_time == null"> modify_time = now(),</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="companyId != null and companyId != ''"> company_id = #{companyId}</if>
        </trim>
        where id=#{id} and sts='Y'
    </update>


    <!-- 多条件逻辑删除 -->
    <update id="entity_delete" parameterType = "com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity" >
        update
        ${dbName}
        set sts= 'N' ,modify_time = now(),modify_user_id = #{modify_user_id}
        <trim prefix="where" prefixOverrides="and">
            <if test="formmainId != null and formmainId != ''"> formmain_id = #{formmainId},</if>
            <if test="sourceName != null and sourceName != ''"> source_name = #{sourceName},</if>
            <if test="code != null and code != ''"> code = #{code},</if>
            <if test="sourceData != null and sourceData != ''"> source_data = #{sourceData},</if>
            <if test="optionType != null and optionType != ''"> option_type = #{optionType},</if>
            <if test="optionName != null and optionName != ''"> option_name = #{optionName},</if>
            <if test="dataType != null and dataType != ''"> data_type = #{dataType},</if>
            <if test="remark != null and remark != ''"> remark = #{remark},</if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
            <if test="sts != null and sts != ''"> and sts = #{sts} </if>
            <if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
            and id=#{id} and sts='Y'
        </trim>
    </update>

</mapper>

