<?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.TcXtjcMapper">
    
    <resultMap type="TcXtjc" id="TcXtjcResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="isStatus"    column="isStatus"    />
        <result property="unitName"    column="unit_name"    />
        <result property="systemName"    column="system_name"    />
        <result property="systemUrl"    column="system_url"    />
        <result property="sysyemIp"    column="sysyem_ip"    />
        <result property="isFocus"    column="is_focus"    />
        <result property="level"    column="level"    />
        <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="selectTcXtjcVo">
        select id, area_id, isStatus, unit_name, system_name, system_url, sysyem_ip, is_focus, level, create_by, create_time, update_by, update_time, remark from tc_xtjc
    </sql>

    <select id="selectTcXtjcList" parameterType="TcXtjc" resultMap="TcXtjcResult">
        <include refid="selectTcXtjcVo"/>
        <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="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="systemName != null  and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
            <if test="systemUrl != null  and systemUrl != ''"> and system_url = #{systemUrl}</if>
            <if test="sysyemIp != null  and sysyemIp != ''"> and sysyem_ip = #{sysyemIp}</if>
            <if test="isFocus != null  and isFocus != ''"> and is_focus = #{isFocus}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectTcXtjcById" parameterType="Long" resultMap="TcXtjcResult">
        <include refid="selectTcXtjcVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcXtjc" parameterType="TcXtjc" useGeneratedKeys="true" keyProperty="id">
        insert into tc_xtjc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="isStatus != null">isStatus,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="systemName != null">system_name,</if>
            <if test="systemUrl != null">system_url,</if>
            <if test="sysyemIp != null">sysyem_ip,</if>
            <if test="isFocus != null">is_focus,</if>
            <if test="level != null">level,</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="unitName != null">#{unitName},</if>
            <if test="systemName != null">#{systemName},</if>
            <if test="systemUrl != null">#{systemUrl},</if>
            <if test="sysyemIp != null">#{sysyemIp},</if>
            <if test="isFocus != null">#{isFocus},</if>
            <if test="level != null">#{level},</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="updateTcXtjc" parameterType="TcXtjc">
        update tc_xtjc
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="isStatus != null">isStatus = #{isStatus},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="systemName != null">system_name = #{systemName},</if>
            <if test="systemUrl != null">system_url = #{systemUrl},</if>
            <if test="sysyemIp != null">sysyem_ip = #{sysyemIp},</if>
            <if test="isFocus != null">is_focus = #{isFocus},</if>
            <if test="level != null">level = #{level},</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_xtjc
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcXtjcById" parameterType="Long">
        delete from tc_xtjc where id = #{id}
    </delete>

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