<?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.ruoyi.invest.mapper.TStudyInformationMapper">
    
    <resultMap type="TStudyInformation" id="TStudyInformationResult">
        <result property="id"    column="id"    />
        <result property="contractName"    column="contract_name"    />
        <result property="contractType"    column="contract_type"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="fileBusinessId"    column="file_business_id"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTStudyInformationVo">
        select id, contract_name, contract_type, del_flag, file_business_id, remark, create_by, create_time, update_by, update_time from t_study_information
    </sql>

    <select id="selectTStudyInformationList" parameterType="TStudyInformation" resultMap="TStudyInformationResult">
        <include refid="selectTStudyInformationVo"/>
        <where>
            del_flag = 0
            <if test="contractName != null  and contractName != ''"> and contract_name like concat('%', #{contractName}, '%')</if>
            <if test="contractType != null  and contractType != ''"> and contract_type = #{contractType}</if>
            <if test="fileBusinessId != null  and fileBusinessId != ''"> and file_business_id = #{fileBusinessId}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
        </where>
    </select>
    
    <select id="selectTStudyInformationById" parameterType="String" resultMap="TStudyInformationResult">
        <include refid="selectTStudyInformationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTStudyInformation" parameterType="TStudyInformation">
        insert into t_study_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="contractName != null">contract_name,</if>
            <if test="contractType != null">contract_type,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="fileBusinessId != null">file_business_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="contractName != null">#{contractName},</if>
            <if test="contractType != null">#{contractType},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="fileBusinessId != null">#{fileBusinessId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTStudyInformation" parameterType="TStudyInformation">
        update t_study_information
        <trim prefix="SET" suffixOverrides=",">
            <if test="contractName != null">contract_name = #{contractName},</if>
            <if test="contractType != null">contract_type = #{contractType},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="fileBusinessId != null">file_business_id = #{fileBusinessId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTStudyInformationById" parameterType="String">
        delete from t_study_information where id = #{id}
    </delete>

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

    <update id="updateTStudyInformationByIds" parameterType="String">
        update t_study_information
        set del_flag = 1
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>