<?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.zongzhi.mapper.TcSgjTjMapper">

    <resultMap type="TcSgjTj" id="TcSgjTjResult">
        <result property="id" column="id"/>
        <result property="townId" column="town_id"/>
        <result property="villageId" column="village_id"/>
        <result property="totalSum" column="total_sum"/>
        <result property="rqSum" column="rq_sum"/>
        <result property="eySum" column="ey_sum"/>
        <result property="jmrSum" column="jmr_sum"/>
        <result property="createId" column="create_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateId" column="update_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="isStatus"    column="is_status"    />
    </resultMap>

    <sql id="selectTcSgjTjVo">
        select id,
               town_id,
               village_id,
               total_sum,
               rq_sum,
               ey_sum,
               jmr_sum,
               create_id,
               create_by,
               create_time,
               update_id,
               update_by,
               update_time,
               remark,
               is_status
        from tc_sgj_tj
    </sql>

    <select id="selectTcSgjTjList" parameterType="TcSgjTj" resultMap="TcSgjTjResult">
        <include refid="selectTcSgjTjVo"/>
        <where>
            <if test="totalSum != null ">and total_sum = #{totalSum}</if>
            <if test="rqSum != null ">and rq_sum = #{rqSum}</if>
            <if test="isStatus != null "> and is_status = #{isStatus}</if>
        </where>
    </select>

    <select id="selectTcSgjTjById" parameterType="Long" resultMap="TcSgjTjResult">
        <include refid="selectTcSgjTjVo"/>
        where id = #{id}
    </select>

    <insert id="insertTcSgjTj" parameterType="TcSgjTj" useGeneratedKeys="true" keyProperty="id">
        insert into tc_sgj_tj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="townId != null">town_id,</if>
            <if test="villageId != null">village_id,</if>
            <if test="totalSum != null">total_sum,</if>
            <if test="rqSum != null">rq_sum,</if>
            <if test="eySum != null">ey_sum,</if>
            <if test="jmrSum != null">jmr_sum,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="isStatus != null">is_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="townId != null">#{townId},</if>
            <if test="villageId != null">#{villageId},</if>
            <if test="totalSum != null">#{totalSum},</if>
            <if test="rqSum != null">#{rqSum},</if>
            <if test="eySum != null">#{eySum},</if>
            <if test="jmrSum != null">#{jmrSum},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isStatus != null">#{isStatus},</if>
        </trim>
    </insert>

    <update id="updateTcSgjTj" parameterType="TcSgjTj">
        update tc_sgj_tj
        <trim prefix="SET" suffixOverrides=",">
            <if test="townId != null">town_id = #{townId},</if>
            <if test="villageId != null">village_id = #{villageId},</if>
            <if test="totalSum != null">total_sum = #{totalSum},</if>
            <if test="rqSum != null">rq_sum = #{rqSum},</if>
            <if test="eySum != null">ey_sum = #{eySum},</if>
            <if test="jmrSum != null">jmr_sum = #{jmrSum},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isStatus != null">is_status=#{isStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcSgjTjById" parameterType="Long">
        delete
        from tc_sgj_tj
        where id = #{id}
    </delete>

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