<?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.zbf.system.mapper.TUserConfigMapper">

    <resultMap type="TUserConfig" id="TUserConfigResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="routerPath"    column="router_path"    />
        <result property="compName"    column="comp_name"    />
        <result property="cnfJson"    column="cnf_json"    />
      <!--  <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />-->
    </resultMap>

    <sql id="selectTUserConfigVo">
        select id, user_id, router_path, comp_name, cnf_json, create_time, create_by, update_time, update_by from t_user_config
    </sql>

    <select id="selectTUserConfigList" parameterType="TUserConfig" resultMap="TUserConfigResult">
        <include refid="selectTUserConfigVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="routerPath != null  and routerPath != ''"> and router_path = #{routerPath}</if>
            <if test="compName != null  and compName != ''"> and comp_name like concat('%', #{compName}, '%')</if>
            <if test="cnfJson != null  and cnfJson != ''"> and cnf_json = #{cnfJson}</if>
        </where>
    </select>

    <select id="selectTUserConfigById" parameterType="Long" resultMap="TUserConfigResult">
        <include refid="selectTUserConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertTUserConfig" parameterType="TUserConfig">
        insert into t_user_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="routerPath != null">router_path,</if>
            <if test="compName != null">comp_name,</if>
            <if test="cnfJson != null">cnf_json,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="routerPath != null">#{routerPath},</if>
            <if test="compName != null">#{compName},</if>
            <if test="cnfJson != null">#{cnfJson},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateTUserConfig" parameterType="TUserConfig">
        update t_user_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="routerPath != null">router_path = #{routerPath},</if>
            <if test="compName != null">comp_name = #{compName},</if>
            <if test="cnfJson != null">cnf_json = #{cnfJson},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="enableTUserConfigByIds" parameterType="String">
        update t_user_config set status=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="disabledTUserConfigByIds" parameterType="String">
        update t_user_config set status=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <delete id="deleteTUserConfigById" parameterType="Long">
        delete from t_user_config  where id = #{id}
    </delete>

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