<?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.rc.mapper.TDeptInfoMapper">
    
    <resultMap type="TDeptInfo" id="TDeptInfoResult">
        <result property="id"    column="id"    />
        <result property="deptInfo"    column="dept_info"    />
        <result property="deptId"    column="dept_id"    />
        <result property="year"    column="year"    />
    </resultMap>

    <sql id="selectTDeptInfoVo">
        select id, dept_info, dept_id, year from t_dept_info
    </sql>

    <select id="selectTDeptInfoList" parameterType="TDeptInfo" resultMap="TDeptInfoResult">
        <include refid="selectTDeptInfoVo"/>
        <where>
            <if test="year != null  and year != ''"> and year = #{year}</if>

            <if test="deptInfo != null  and deptInfo != ''"> and dept_info = #{deptInfo}</if>
            <if test="deptId != null "> and dept_id like concat(concat('%', #{deptId}), '%')</if>
        </where>
    </select>
    
    <select id="selectTDeptInfoById" parameterType="Long" resultMap="TDeptInfoResult">
        <include refid="selectTDeptInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDeptInfo" parameterType="TDeptInfo" useGeneratedKeys="true" keyProperty="id">
        insert into t_dept_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptInfo != null">dept_info,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="year != null">year,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptInfo != null">#{deptInfo},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="year != null">#{year},</if>
         </trim>
    </insert>

    <update id="updateTDeptInfo" parameterType="TDeptInfo">
        update t_dept_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptInfo != null">dept_info = #{deptInfo},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="year != null">year = #{year},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDeptInfoById" parameterType="Long">
        delete from t_dept_info where id = #{id}
    </delete>

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