<?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.tofly.scada.mapper.UserXMapper">

    <resultMap id="BaseResultMap" type="com.tofly.scada.entity.UserX">
            <result property="id" column="ID" jdbcType="DECIMAL"/>
            <result property="username" column="USERNAME" jdbcType="VARCHAR"/>
            <result property="password" column="PASSWORD" jdbcType="VARCHAR"/>
            <result property="salt" column="SALT" jdbcType="VARCHAR"/>
            <result property="phone" column="PHONE" jdbcType="VARCHAR"/>
            <result property="avatar" column="AVATAR" jdbcType="VARCHAR"/>
            <result property="departmentId" column="DEPARTMENT_ID" jdbcType="DECIMAL"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="lockFlag" column="LOCK_FLAG" jdbcType="CHAR"/>
            <result property="statusFlag" column="STATUS_FLAG" jdbcType="CHAR"/>
            <result property="wxOpenid" column="WX_OPENID" jdbcType="VARCHAR"/>
            <result property="qqOpenid" column="QQ_OPENID" jdbcType="VARCHAR"/>
            <result property="email" column="EMAIL" jdbcType="VARCHAR"/>
            <result property="realName" column="REAL_NAME" jdbcType="VARCHAR"/>
            <result property="loginTime" column="LOGIN_TIME" jdbcType="TIMESTAMP"/>
            <result property="lastIp" column="LAST_IP" jdbcType="VARCHAR"/>
            <result property="pwderrtimes" column="PWDERRTIMES" jdbcType="DECIMAL"/>
            <result property="worknumber" column="WORKNUMBER" jdbcType="VARCHAR"/>
            <result property="findpwdkey" column="FINDPWDKEY" jdbcType="VARCHAR"/>
            <result property="aliasname" column="ALIASNAME" jdbcType="VARCHAR"/>
            <result property="birthday" column="BIRTHDAY" jdbcType="TIMESTAMP"/>
            <result property="belong" column="BELONG" jdbcType="VARCHAR"/>
            <result property="createUser" column="CREATE_USER" jdbcType="DECIMAL"/>
            <result property="userLevel" column="USER_LEVEL" jdbcType="CHAR"/>
            <result property="esignature" column="ESIGNATURE" jdbcType="VARCHAR"/>
            <result property="createType" column="CREATE_TYPE" jdbcType="CHAR"/>
            <result property="firstlog" column="FIRSTLOG" jdbcType="CHAR"/>
            <result property="applyer" column="APPLYER" jdbcType="VARCHAR"/>
            <result property="applytime" column="APPLYTIME" jdbcType="TIMESTAMP"/>
            <result property="applystate" column="APPLYSTATE" jdbcType="VARCHAR"/>
            <result property="auditor" column="AUDITOR" jdbcType="VARCHAR"/>
            <result property="accountstate" column="ACCOUNTSTATE" jdbcType="VARCHAR"/>
            <result property="audittime" column="AUDITTIME" jdbcType="TIMESTAMP"/>
            <result property="auditstate" column="AUDITSTATE" jdbcType="VARCHAR"/>
            <result property="auditstatus" column="AUDITSTATUS" jdbcType="CHAR"/>
            <result property="note" column="NOTE" jdbcType="VARCHAR"/>
            <result property="enableFlag" column="ENABLE_FLAG" jdbcType="CHAR"/>
            <result property="originalPassword" column="ORIGINAL_PASSWORD" jdbcType="VARCHAR"/>
            <result property="job" column="JOB" jdbcType="VARCHAR"/>
            <result property="parentCompanyId" column="PARENT_COMPANY_ID" jdbcType="DECIMAL"/>
            <result property="companyId" column="COMPANY_ID" jdbcType="DECIMAL"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,USERNAME,PASSWORD,
        SALT,PHONE,AVATAR,
        DEPARTMENT_ID,CREATE_TIME,UPDATE_TIME,
        LOCK_FLAG,STATUS_FLAG,WX_OPENID,
        QQ_OPENID,EMAIL,REAL_NAME,
        LOGIN_TIME,LAST_IP,PWDERRTIMES,
        WORKNUMBER,FINDPWDKEY,ALIASNAME,
        BIRTHDAY,BELONG,CREATE_USER,
        USER_LEVEL,ESIGNATURE,CREATE_TYPE,
        FIRSTLOG,APPLYER,APPLYTIME,
        APPLYSTATE,AUDITOR,ACCOUNTSTATE,
        AUDITTIME,AUDITSTATE,AUDITSTATUS,
        NOTE,ENABLE_FLAG,ORIGINAL_PASSWORD,
        JOB,PARENT_COMPANY_ID,COMPANY_ID
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from TF_SMPN_USER_X
        where ID = #{id}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from TF_XRTF_UDB.TF_SMPN_USER_X
        where ID = #{id}
    </delete>
    <insert id="insert">
        insert into TF_XRTF_UDB.TF_SMPN_USER_X
        ( ID,USERNAME,PASSWORD
        ,SALT,PHONE,AVATAR
        ,DEPARTMENT_ID,CREATE_TIME,UPDATE_TIME
        ,LOCK_FLAG,STATUS_FLAG,WX_OPENID
        ,QQ_OPENID,EMAIL,REAL_NAME
        ,LOGIN_TIME,LAST_IP,PWDERRTIMES
        ,WORKNUMBER,FINDPWDKEY,ALIASNAME
        ,BIRTHDAY,BELONG,CREATE_USER
        ,USER_LEVEL,ESIGNATURE,CREATE_TYPE
        ,FIRSTLOG,APPLYER,APPLYTIME
        ,APPLYSTATE,AUDITOR,ACCOUNTSTATE
        ,AUDITTIME,AUDITSTATE,AUDITSTATUS
        ,NOTE,ENABLE_FLAG,ORIGINAL_PASSWORD
        ,JOB,PARENT_COMPANY_ID,COMPANY_ID
        )
        values (#{id,jdbcType=DECIMAL},#{username,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR}
        ,#{salt,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR},#{avatar,jdbcType=VARCHAR}
        ,#{departmentId,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}
        ,#{lockFlag,jdbcType=CHAR},#{statusFlag,jdbcType=CHAR},#{wxOpenid,jdbcType=VARCHAR}
        ,#{qqOpenid,jdbcType=VARCHAR},#{email,jdbcType=VARCHAR},#{realName,jdbcType=VARCHAR}
        ,#{loginTime,jdbcType=TIMESTAMP},#{lastIp,jdbcType=VARCHAR},#{pwderrtimes,jdbcType=DECIMAL}
        ,#{worknumber,jdbcType=VARCHAR},#{findpwdkey,jdbcType=VARCHAR},#{aliasname,jdbcType=VARCHAR}
        ,#{birthday,jdbcType=TIMESTAMP},#{belong,jdbcType=VARCHAR},#{createUser,jdbcType=DECIMAL}
        ,#{userLevel,jdbcType=CHAR},#{esignature,jdbcType=VARCHAR},#{createType,jdbcType=CHAR}
        ,#{firstlog,jdbcType=CHAR},#{applyer,jdbcType=VARCHAR},#{applytime,jdbcType=TIMESTAMP}
        ,#{applystate,jdbcType=VARCHAR},#{auditor,jdbcType=VARCHAR},#{accountstate,jdbcType=VARCHAR}
        ,#{audittime,jdbcType=TIMESTAMP},#{auditstate,jdbcType=VARCHAR},#{auditstatus,jdbcType=CHAR}
        ,#{note,jdbcType=VARCHAR},#{enableFlag,jdbcType=CHAR},#{originalPassword,jdbcType=VARCHAR}
        ,#{job,jdbcType=VARCHAR},#{parentCompanyId,jdbcType=DECIMAL},#{companyId,jdbcType=DECIMAL}
        )
    </insert>
    <insert id="insertSelective">
        insert into TF_XRTF_UDB.TF_SMPN_USER_X
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">ID,</if>
                <if test="username != null">USERNAME,</if>
                <if test="password != null">PASSWORD,</if>
                <if test="salt != null">SALT,</if>
                <if test="phone != null">PHONE,</if>
                <if test="avatar != null">AVATAR,</if>
                <if test="departmentId != null">DEPARTMENT_ID,</if>
                <if test="createTime != null">CREATE_TIME,</if>
                <if test="updateTime != null">UPDATE_TIME,</if>
                <if test="lockFlag != null">LOCK_FLAG,</if>
                <if test="statusFlag != null">STATUS_FLAG,</if>
                <if test="wxOpenid != null">WX_OPENID,</if>
                <if test="qqOpenid != null">QQ_OPENID,</if>
                <if test="email != null">EMAIL,</if>
                <if test="realName != null">REAL_NAME,</if>
                <if test="loginTime != null">LOGIN_TIME,</if>
                <if test="lastIp != null">LAST_IP,</if>
                <if test="pwderrtimes != null">PWDERRTIMES,</if>
                <if test="worknumber != null">WORKNUMBER,</if>
                <if test="findpwdkey != null">FINDPWDKEY,</if>
                <if test="aliasname != null">ALIASNAME,</if>
                <if test="birthday != null">BIRTHDAY,</if>
                <if test="belong != null">BELONG,</if>
                <if test="createUser != null">CREATE_USER,</if>
                <if test="userLevel != null">USER_LEVEL,</if>
                <if test="esignature != null">ESIGNATURE,</if>
                <if test="createType != null">CREATE_TYPE,</if>
                <if test="firstlog != null">FIRSTLOG,</if>
                <if test="applyer != null">APPLYER,</if>
                <if test="applytime != null">APPLYTIME,</if>
                <if test="applystate != null">APPLYSTATE,</if>
                <if test="auditor != null">AUDITOR,</if>
                <if test="accountstate != null">ACCOUNTSTATE,</if>
                <if test="audittime != null">AUDITTIME,</if>
                <if test="auditstate != null">AUDITSTATE,</if>
                <if test="auditstatus != null">AUDITSTATUS,</if>
                <if test="note != null">NOTE,</if>
                <if test="enableFlag != null">ENABLE_FLAG,</if>
                <if test="originalPassword != null">ORIGINAL_PASSWORD,</if>
                <if test="job != null">JOB,</if>
                <if test="parentCompanyId != null">PARENT_COMPANY_ID,</if>
                <if test="companyId != null">COMPANY_ID,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=DECIMAL},</if>
                <if test="username != null">#{username,jdbcType=VARCHAR},</if>
                <if test="password != null">#{password,jdbcType=VARCHAR},</if>
                <if test="salt != null">#{salt,jdbcType=VARCHAR},</if>
                <if test="phone != null">#{phone,jdbcType=VARCHAR},</if>
                <if test="avatar != null">#{avatar,jdbcType=VARCHAR},</if>
                <if test="departmentId != null">#{departmentId,jdbcType=DECIMAL},</if>
                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
                <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
                <if test="lockFlag != null">#{lockFlag,jdbcType=CHAR},</if>
                <if test="statusFlag != null">#{statusFlag,jdbcType=CHAR},</if>
                <if test="wxOpenid != null">#{wxOpenid,jdbcType=VARCHAR},</if>
                <if test="qqOpenid != null">#{qqOpenid,jdbcType=VARCHAR},</if>
                <if test="email != null">#{email,jdbcType=VARCHAR},</if>
                <if test="realName != null">#{realName,jdbcType=VARCHAR},</if>
                <if test="loginTime != null">#{loginTime,jdbcType=TIMESTAMP},</if>
                <if test="lastIp != null">#{lastIp,jdbcType=VARCHAR},</if>
                <if test="pwderrtimes != null">#{pwderrtimes,jdbcType=DECIMAL},</if>
                <if test="worknumber != null">#{worknumber,jdbcType=VARCHAR},</if>
                <if test="findpwdkey != null">#{findpwdkey,jdbcType=VARCHAR},</if>
                <if test="aliasname != null">#{aliasname,jdbcType=VARCHAR},</if>
                <if test="birthday != null">#{birthday,jdbcType=TIMESTAMP},</if>
                <if test="belong != null">#{belong,jdbcType=VARCHAR},</if>
                <if test="createUser != null">#{createUser,jdbcType=DECIMAL},</if>
                <if test="userLevel != null">#{userLevel,jdbcType=CHAR},</if>
                <if test="esignature != null">#{esignature,jdbcType=VARCHAR},</if>
                <if test="createType != null">#{createType,jdbcType=CHAR},</if>
                <if test="firstlog != null">#{firstlog,jdbcType=CHAR},</if>
                <if test="applyer != null">#{applyer,jdbcType=VARCHAR},</if>
                <if test="applytime != null">#{applytime,jdbcType=TIMESTAMP},</if>
                <if test="applystate != null">#{applystate,jdbcType=VARCHAR},</if>
                <if test="auditor != null">#{auditor,jdbcType=VARCHAR},</if>
                <if test="accountstate != null">#{accountstate,jdbcType=VARCHAR},</if>
                <if test="audittime != null">#{audittime,jdbcType=TIMESTAMP},</if>
                <if test="auditstate != null">#{auditstate,jdbcType=VARCHAR},</if>
                <if test="auditstatus != null">#{auditstatus,jdbcType=CHAR},</if>
                <if test="note != null">#{note,jdbcType=VARCHAR},</if>
                <if test="enableFlag != null">#{enableFlag,jdbcType=CHAR},</if>
                <if test="originalPassword != null">#{originalPassword,jdbcType=VARCHAR},</if>
                <if test="job != null">#{job,jdbcType=VARCHAR},</if>
                <if test="parentCompanyId != null">#{parentCompanyId,jdbcType=DECIMAL},</if>
                <if test="companyId != null">#{companyId,jdbcType=DECIMAL},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.tofly.scada.entity.UserX">
        update TF_XRTF_UDB.TF_SMPN_USER_X
        <set>
                <if test="id != null">
                    ID = #{id,jdbcType=DECIMAL},
                </if>
                <if test="username != null">
                    USERNAME = #{username,jdbcType=VARCHAR},
                </if>
                <if test="password != null">
                    PASSWORD = #{password,jdbcType=VARCHAR},
                </if>
                <if test="salt != null">
                    SALT = #{salt,jdbcType=VARCHAR},
                </if>
                <if test="phone != null">
                    PHONE = #{phone,jdbcType=VARCHAR},
                </if>
                <if test="avatar != null">
                    AVATAR = #{avatar,jdbcType=VARCHAR},
                </if>
                <if test="departmentId != null">
                    DEPARTMENT_ID = #{departmentId,jdbcType=DECIMAL},
                </if>
                <if test="createTime != null">
                    CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
                </if>
                <if test="updateTime != null">
                    UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
                </if>
                <if test="lockFlag != null">
                    LOCK_FLAG = #{lockFlag,jdbcType=CHAR},
                </if>
                <if test="statusFlag != null">
                    STATUS_FLAG = #{statusFlag,jdbcType=CHAR},
                </if>
                <if test="wxOpenid != null">
                    WX_OPENID = #{wxOpenid,jdbcType=VARCHAR},
                </if>
                <if test="qqOpenid != null">
                    QQ_OPENID = #{qqOpenid,jdbcType=VARCHAR},
                </if>
                <if test="email != null">
                    EMAIL = #{email,jdbcType=VARCHAR},
                </if>
                <if test="realName != null">
                    REAL_NAME = #{realName,jdbcType=VARCHAR},
                </if>
                <if test="loginTime != null">
                    LOGIN_TIME = #{loginTime,jdbcType=TIMESTAMP},
                </if>
                <if test="lastIp != null">
                    LAST_IP = #{lastIp,jdbcType=VARCHAR},
                </if>
                <if test="pwderrtimes != null">
                    PWDERRTIMES = #{pwderrtimes,jdbcType=DECIMAL},
                </if>
                <if test="worknumber != null">
                    WORKNUMBER = #{worknumber,jdbcType=VARCHAR},
                </if>
                <if test="findpwdkey != null">
                    FINDPWDKEY = #{findpwdkey,jdbcType=VARCHAR},
                </if>
                <if test="aliasname != null">
                    ALIASNAME = #{aliasname,jdbcType=VARCHAR},
                </if>
                <if test="birthday != null">
                    BIRTHDAY = #{birthday,jdbcType=TIMESTAMP},
                </if>
                <if test="belong != null">
                    BELONG = #{belong,jdbcType=VARCHAR},
                </if>
                <if test="createUser != null">
                    CREATE_USER = #{createUser,jdbcType=DECIMAL},
                </if>
                <if test="userLevel != null">
                    USER_LEVEL = #{userLevel,jdbcType=CHAR},
                </if>
                <if test="esignature != null">
                    ESIGNATURE = #{esignature,jdbcType=VARCHAR},
                </if>
                <if test="createType != null">
                    CREATE_TYPE = #{createType,jdbcType=CHAR},
                </if>
                <if test="firstlog != null">
                    FIRSTLOG = #{firstlog,jdbcType=CHAR},
                </if>
                <if test="applyer != null">
                    APPLYER = #{applyer,jdbcType=VARCHAR},
                </if>
                <if test="applytime != null">
                    APPLYTIME = #{applytime,jdbcType=TIMESTAMP},
                </if>
                <if test="applystate != null">
                    APPLYSTATE = #{applystate,jdbcType=VARCHAR},
                </if>
                <if test="auditor != null">
                    AUDITOR = #{auditor,jdbcType=VARCHAR},
                </if>
                <if test="accountstate != null">
                    ACCOUNTSTATE = #{accountstate,jdbcType=VARCHAR},
                </if>
                <if test="audittime != null">
                    AUDITTIME = #{audittime,jdbcType=TIMESTAMP},
                </if>
                <if test="auditstate != null">
                    AUDITSTATE = #{auditstate,jdbcType=VARCHAR},
                </if>
                <if test="auditstatus != null">
                    AUDITSTATUS = #{auditstatus,jdbcType=CHAR},
                </if>
                <if test="note != null">
                    NOTE = #{note,jdbcType=VARCHAR},
                </if>
                <if test="enableFlag != null">
                    ENABLE_FLAG = #{enableFlag,jdbcType=CHAR},
                </if>
                <if test="originalPassword != null">
                    ORIGINAL_PASSWORD = #{originalPassword,jdbcType=VARCHAR},
                </if>
                <if test="job != null">
                    JOB = #{job,jdbcType=VARCHAR},
                </if>
                <if test="parentCompanyId != null">
                    PARENT_COMPANY_ID = #{parentCompanyId,jdbcType=DECIMAL},
                </if>
                <if test="companyId != null">
                    COMPANY_ID = #{companyId,jdbcType=DECIMAL},
                </if>
        </set>
        where ID = #{id}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.tofly.scada.entity.UserX">
        update TF_XRTF_UDB.TF_SMPN_USER_X
        set 
            ID =  #{id,jdbcType=DECIMAL},
            USERNAME =  #{username,jdbcType=VARCHAR},
            PASSWORD =  #{password,jdbcType=VARCHAR},
            SALT =  #{salt,jdbcType=VARCHAR},
            PHONE =  #{phone,jdbcType=VARCHAR},
            AVATAR =  #{avatar,jdbcType=VARCHAR},
            DEPARTMENT_ID =  #{departmentId,jdbcType=DECIMAL},
            CREATE_TIME =  #{createTime,jdbcType=TIMESTAMP},
            UPDATE_TIME =  #{updateTime,jdbcType=TIMESTAMP},
            LOCK_FLAG =  #{lockFlag,jdbcType=CHAR},
            STATUS_FLAG =  #{statusFlag,jdbcType=CHAR},
            WX_OPENID =  #{wxOpenid,jdbcType=VARCHAR},
            QQ_OPENID =  #{qqOpenid,jdbcType=VARCHAR},
            EMAIL =  #{email,jdbcType=VARCHAR},
            REAL_NAME =  #{realName,jdbcType=VARCHAR},
            LOGIN_TIME =  #{loginTime,jdbcType=TIMESTAMP},
            LAST_IP =  #{lastIp,jdbcType=VARCHAR},
            PWDERRTIMES =  #{pwderrtimes,jdbcType=DECIMAL},
            WORKNUMBER =  #{worknumber,jdbcType=VARCHAR},
            FINDPWDKEY =  #{findpwdkey,jdbcType=VARCHAR},
            ALIASNAME =  #{aliasname,jdbcType=VARCHAR},
            BIRTHDAY =  #{birthday,jdbcType=TIMESTAMP},
            BELONG =  #{belong,jdbcType=VARCHAR},
            CREATE_USER =  #{createUser,jdbcType=DECIMAL},
            USER_LEVEL =  #{userLevel,jdbcType=CHAR},
            ESIGNATURE =  #{esignature,jdbcType=VARCHAR},
            CREATE_TYPE =  #{createType,jdbcType=CHAR},
            FIRSTLOG =  #{firstlog,jdbcType=CHAR},
            APPLYER =  #{applyer,jdbcType=VARCHAR},
            APPLYTIME =  #{applytime,jdbcType=TIMESTAMP},
            APPLYSTATE =  #{applystate,jdbcType=VARCHAR},
            AUDITOR =  #{auditor,jdbcType=VARCHAR},
            ACCOUNTSTATE =  #{accountstate,jdbcType=VARCHAR},
            AUDITTIME =  #{audittime,jdbcType=TIMESTAMP},
            AUDITSTATE =  #{auditstate,jdbcType=VARCHAR},
            AUDITSTATUS =  #{auditstatus,jdbcType=CHAR},
            NOTE =  #{note,jdbcType=VARCHAR},
            ENABLE_FLAG =  #{enableFlag,jdbcType=CHAR},
            ORIGINAL_PASSWORD =  #{originalPassword,jdbcType=VARCHAR},
            JOB =  #{job,jdbcType=VARCHAR},
            PARENT_COMPANY_ID =  #{parentCompanyId,jdbcType=DECIMAL},
            COMPANY_ID =  #{companyId,jdbcType=DECIMAL}
        where ID = #{id}
    </update>
</mapper>
