<?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.tcZz.mapper.TcAqgMapper">
    
    <resultMap type="TcAqg" id="TcAqgResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="isStatus"    column="isStatus"    />
        <result property="unit"    column="unit"    />
        <result property="fzr"    column="fzr"    />
        <result property="duty"    column="duty"    />
        <result property="fzr1"    column="fzr1"    />
        <result property="duty1"    column="duty1"    />
        <result property="fzks"    column="fzks"    />
        <result property="fzr3"    column="fzr3"    />
        <result property="duty3"    column="duty3"    />
        <result property="tel"    column="tel"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcAqgVo">
        select id, area_id, isStatus, unit, fzr, duty, fzr1, duty1, fzks, fzr3, duty3, tel, create_by, create_time, update_by, update_time, remark from tc_aqg
    </sql>

    <select id="selectTcAqgList" parameterType="TcAqg" resultMap="TcAqgResult">
        <include refid="selectTcAqgVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="areaId != null  and areaId != ''"> and area_id = #{areaId}</if>
            <if test="isStatus != null "> and isStatus = #{isStatus}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="fzr != null  and fzr != ''"> and fzr = #{fzr}</if>
            <if test="duty != null  and duty != ''"> and duty = #{duty}</if>
            <if test="fzr1 != null  and fzr1 != ''"> and fzr1 = #{fzr1}</if>
            <if test="duty1 != null  and duty1 != ''"> and duty1 = #{duty1}</if>
            <if test="fzks != null  and fzks != ''"> and fzks = #{fzks}</if>
            <if test="fzr3 != null  and fzr3 != ''"> and fzr3 = #{fzr3}</if>
            <if test="duty3 != null  and duty3 != ''"> and duty3 = #{duty3}</if>
            <if test="tel != null  and tel != ''"> and tel = #{tel}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
            <if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''"> and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectTcAqgById" parameterType="Long" resultMap="TcAqgResult">
        <include refid="selectTcAqgVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcAqg" parameterType="TcAqg" useGeneratedKeys="true" keyProperty="id">
        insert into tc_aqg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="isStatus != null">isStatus,</if>
            <if test="unit != null">unit,</if>
            <if test="fzr != null">fzr,</if>
            <if test="duty != null">duty,</if>
            <if test="fzr1 != null">fzr1,</if>
            <if test="duty1 != null">duty1,</if>
            <if test="fzks != null">fzks,</if>
            <if test="fzr3 != null">fzr3,</if>
            <if test="duty3 != null">duty3,</if>
            <if test="tel != null">tel,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="isStatus != null">#{isStatus},</if>
            <if test="unit != null">#{unit},</if>
            <if test="fzr != null">#{fzr},</if>
            <if test="duty != null">#{duty},</if>
            <if test="fzr1 != null">#{fzr1},</if>
            <if test="duty1 != null">#{duty1},</if>
            <if test="fzks != null">#{fzks},</if>
            <if test="fzr3 != null">#{fzr3},</if>
            <if test="duty3 != null">#{duty3},</if>
            <if test="tel != null">#{tel},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcAqg" parameterType="TcAqg">
        update tc_aqg
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="isStatus != null">isStatus = #{isStatus},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="fzr != null">fzr = #{fzr},</if>
            <if test="duty != null">duty = #{duty},</if>
            <if test="fzr1 != null">fzr1 = #{fzr1},</if>
            <if test="duty1 != null">duty1 = #{duty1},</if>
            <if test="fzks != null">fzks = #{fzks},</if>
            <if test="fzr3 != null">fzr3 = #{fzr3},</if>
            <if test="duty3 != null">duty3 = #{duty3},</if>
            <if test="tel != null">tel = #{tel},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
    <update id="updateByisStatus">
        UPDATE tc_aqg
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcAqgById" parameterType="Long">
        delete from tc_aqg where id = #{id}
    </delete>

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

</mapper>