<?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="cn.iocoder.yudao.module.contract.mapper.ContractManagementMapper">

    <resultMap type="cn.iocoder.yudao.module.contract.entity.ContractManagement" id="ContractManagementResult">
        <result property="id"    column="id"    />
        <result property="contractName"    column="contract_name"    />
        <result property="contractFilePath"    column="contract_file_path"    />
        <result property="positionJson"    column="position_json"    />
        <result property="orderNum"    column="order_num"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectContractManagementVo">
        select id, contract_name, contract_file_path, position_json, order_num,create_time, creator, update_time, updater from contract_management
    </sql>

    <select id="selectContractManagementList" parameterType="cn.iocoder.yudao.module.contract.entity.ContractManagement" resultMap="ContractManagementResult">
        <include refid="selectContractManagementVo"/>
        <where>
            <if test="contractName != null  and contractName != ''"> and contract_name like concat('%', #{contractName}, '%')</if>
            <if test="contractFilePath != null  and contractFilePath != ''"> and contract_file_path = #{contractFilePath}</if>
            <if test="positionJson != null  and positionJson != ''"> and position_json = #{positionJson}</if>
        </where>
        order by order_num
    </select>

    <select id="selectContractManagementById" parameterType="Long" resultMap="ContractManagementResult">
        <include refid="selectContractManagementVo"/>
        where id = #{id}
    </select>

    <insert id="insertContractManagement" parameterType="cn.iocoder.yudao.module.contract.entity.ContractManagement">
        insert into contract_management
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="contractName != null">contract_name,</if>
            <if test="contractFilePath != null">contract_file_path,</if>
            <if test="positionJson != null">position_json,</if>
            <if test="orderNum != null">order_num,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="contractName != null">#{contractName},</if>
            <if test="contractFilePath != null">#{contractFilePath},</if>
            <if test="positionJson != null">#{positionJson},</if>
            <if test="orderNum != null">#{orderNum},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateContractManagement" parameterType="cn.iocoder.yudao.module.contract.entity.ContractManagement">
        update contract_management
        <trim prefix="SET" suffixOverrides=",">
            <if test="contractName != null">contract_name = #{contractName},</if>
            <if test="contractFilePath != null">contract_file_path = #{contractFilePath},</if>
            <if test="positionJson != null">position_json = #{positionJson},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteContractManagementById" parameterType="Long">
        delete from contract_management where id = #{id}
    </delete>

    <delete id="deleteContractManagementByIds" parameterType="String">
        delete from contract_management where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
