<?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.SysUserBusinessColumnMapper">

    <resultMap type="SysUserBusinessColumn" id="SysUserBusinessColumnResult">
            <result property="ID"    column="ID"    />
            <result property="userName"    column="USER_NAME"    />
            <result property="businessCode"    column="BUSINESS_CODE"    />
            <result property="tableNo"    column="TABLE_NO"    />
            <result property="columnShow"    column="COLUMN_SHOW"    />
            <result property="columnHide"    column="COLUMN_HIDE"    />
            <result property="delFlag"    column="DEL_FLAG"    />
            <result property="loginIp"    column="LOGIN_IP"    />
            <result property="loginDate"    column="LOGIN_DATE"    />
            <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="selectSysUserBusinessColumnVo">
        select ID, USER_NAME, BUSINESS_CODE, TABLE_NO, COLUMN_SHOW, COLUMN_HIDE, DEL_FLAG, LOGIN_IP, LOGIN_DATE, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK from SYS_USER_BUSINESS_COLUMN
    </sql>

    <select id="selectSysUserBusinessColumnList" parameterType="SysUserBusinessColumn" resultMap="SysUserBusinessColumnResult">
        <include refid="selectSysUserBusinessColumnVo"/>
        <where>
                        <if test="userName != null  and userName != ''"> and USER_NAME = #{userName}</if>
                        <if test="businessCode != null  and businessCode != ''"> and BUSINESS_CODE = #{businessCode}</if>
                        <if test="tableNo != null "> and TABLE_NO = #{tableNo}</if>
                        <if test="columnShow != null  and columnShow != ''"> and COLUMN_SHOW = #{columnShow}</if>
                        <if test="columnHide != null  and columnHide != ''"> and COLUMN_HIDE = #{columnHide}</if>
                        <if test="delFlag != null  and delFlag != ''"> and DEL_FLAG = #{delFlag}</if>
                        <if test="loginIp != null  and loginIp != ''"> and LOGIN_IP = #{loginIp}</if>
                        <if test="loginDate != null "> and LOGIN_DATE = #{loginDate}</if>
                        <if test="createBy != null  and createBy != ''"> and CREATE_BY = #{createBy}</if>
                        <if test="createTime != null "> and CREATE_TIME = #{createTime}</if>
                        <if test="updateBy != null  and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
                        <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
                        <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
        </where>
    </select>

    <select id="selectSysUserBusinessColumnByID" parameterType="Long" resultMap="SysUserBusinessColumnResult">
            <include refid="selectSysUserBusinessColumnVo"/>
            where ID = #{ID}
    </select>

    <insert id="insertSysUserBusinessColumn" parameterType="SysUserBusinessColumn" useGeneratedKeys="true" keyProperty="ID">
        insert into SYS_USER_BUSINESS_COLUMN
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="userName != null and userName != ''">USER_NAME,</if>
                    <!--<if test="businessCode != null and businessCode != ''">BUSINESS_CODE,</if>-->
                    <if test="tableNo != null">TABLE_NO,</if>
                    <if test="columnShow != null and columnShow != ''">COLUMN_SHOW,</if>
                    <if test="columnHide != null and columnHide != ''">COLUMN_HIDE,</if>
                    <if test="delFlag != null">DEL_FLAG,</if>
                    <if test="loginIp != null">LOGIN_IP,</if>
                    <if test="loginDate != null">LOGIN_DATE,</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="userName != null and userName != ''">#{userName},</if>
<!--
                    <if test="businessCode != null and businessCode != ''">#{businessCode},</if>
-->
                    <if test="tableNo != null">#{tableNo},</if>
                    <if test="columnShow != null and columnShow != ''">#{columnShow},</if>
                    <if test="columnHide != null and columnHide != ''">#{columnHide},</if>
                    <if test="delFlag != null">#{delFlag},</if>
                    <if test="loginIp != null">#{loginIp},</if>
                    <if test="loginDate != null">#{loginDate},</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="updateSysUserBusinessColumn" parameterType="SysUserBusinessColumn">
        update SYS_USER_BUSINESS_COLUMN
        <trim prefix="SET" suffixOverrides=",">
                    <if test="userName != null and userName != ''">USER_NAME = #{userName},</if>
                    <if test="businessCode != null and businessCode != ''">BUSINESS_CODE = #{businessCode},</if>
                    <if test="tableNo != null">TABLE_NO = #{tableNo},</if>
                    <if test="columnShow != null and columnShow != ''">COLUMN_SHOW = #{columnShow},</if>
                    <if test="columnHide != null and columnHide != ''">COLUMN_HIDE = #{columnHide},</if>
                    <if test="delFlag != null">DEL_FLAG = #{delFlag},</if>
                    <if test="loginIp != null">LOGIN_IP = #{loginIp},</if>
                    <if test="loginDate != null">LOGIN_DATE = #{loginDate},</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="enableSysUserBusinessColumnByIds" parameterType="String">
        update SYS_USER_BUSINESS_COLUMN set status=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="disabledSysUserBusinessColumnByIds" parameterType="String">
        update SYS_USER_BUSINESS_COLUMN set status=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <delete id="deleteSysUserBusinessColumnByID" parameterType="Long">
        delete from SYS_USER_BUSINESS_COLUMN  where ID = #{ID}
    </delete>

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