<?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.dao.impl.ComparisonDetailsDaoImpl">
    <resultMap id="get-ComparisonDetailsEntity-result" type="com.hzya.frame.sysnew.comparison.entity.ComparisonDetailsEntity" >
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="documentRule" column="document_rule" jdbcType="VARCHAR"/>
        <result property="documentRuleNum" column="document_rule_num" jdbcType="VARCHAR"/>
        <result property="formmainId" column="formmain_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"/>
    </resultMap>

    <select id="queryComparisonDetailsPage" resultType="java.util.Map"
            parameterType="com.hzya.frame.sysnew.comparison.entity.ComparisonDetailsEntity">
        select * from ${dbName}
            where formmain_id=#{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
    </select>



    <insert id="saveComparisonDetails" parameterType = "java.util.Map">
        insert into ${dbName}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <foreach collection="mapDetails.keySet()" item="column">
                ${column},
            </foreach>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <foreach collection="mapDetails.values()" item="value">
                #{value},
            </foreach>
        </trim>
    </insert>

    <!--通过主键修改方法-->
    <update id="updateComparisonDetailsByType" parameterType = "java.util.Map" >
        update ${dbName}
        <set>
            <foreach collection="mapDetails.entrySet()" item="value" index="key" separator=",">
                ${key} =#{value}
            </foreach>
        </set>
        where data_id=#{dataId} and formmain_id= #{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
    </update>

    <!-- 多条件逻辑删除 -->
    <update id="deleteComparisonDetails" parameterType = "java.util.Map" >
        update
        ${dbName}
        set modify_time = now(),modify_user_id = #{modify_user_id}, data_status= 'N'
        <trim prefix="where" prefixOverrides="and">
            <!--<foreach collection="mapDetails.entrySet()" item="value" index="key">
                ${key} =#{value}
            </foreach>-->
           and formmain_id=#{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
        </trim>
    </update>

</mapper>

