<?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.interfaces.mapper.PtAppUserDao">
    <resultMap type="com.ruoyi.interfaces.domain.PtAppUser" id="ptAppUserResultMap">
        <result property="userId" column="USER_ID" jdbcType="VARCHAR"/>
        <result property="userSalt" column="USER_SALT" jdbcType="VARCHAR"/>
        <result property="userName" column="USER_NAME" jdbcType="VARCHAR"/>
        <result property="userPass" column="USER_PASS" jdbcType="VARCHAR"/>
        <result property="userRegdate" column="USER_REGDATE" jdbcType="VARCHAR"/>
        <result property="userType" column="USER_TYPE" jdbcType="VARCHAR"/>
        <result property="userLastdate" column="USER_LASTDATE" jdbcType="VARCHAR"/>
        <result property="userCount" column="USER_COUNT" jdbcType="VARCHAR"/>
        <result property="userStatus" column="USER_STATUS" jdbcType="VARCHAR"/>
        <result property="userEmail" column="USER_EMAIL" jdbcType="VARCHAR"/>
        <result property="userPhone" column="USER_PHONE" jdbcType="VARCHAR"/>
        <result property="userUnit" column="USER_UNIT" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="table_columns">
        USER_ID
        ,
		USER_SALT,
		USER_NAME,
		USER_PASS,
		USER_REGDATE,
		USER_TYPE,
		USER_LASTDATE,
		USER_COUNT,
		USER_STATUS,
		USER_EMAIL,
        USER_PHONE,
        USER_UNIT
    </sql>
    <sql id="entity_properties">
        #{userId,jdbcType=VARCHAR}
        ,
        #{userSalt,jdbcType=VARCHAR},
        #{userName,jdbcType=VARCHAR},
        #{userPass,jdbcType=VARCHAR},
        #{userRegdate,jdbcType=VARCHAR},
        #{userType,jdbcType=VARCHAR},
        #{userLastdate,jdbcType=VARCHAR},
        #{userCount,jdbcType=VARCHAR},
        #{userStatus,jdbcType=VARCHAR},
        #{userEmail,jdbcType=VARCHAR},
        #{userPhone,jdbcType=VARCHAR},
        #{userUnit,jdbcType=VARCHAR}
    </sql>


    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.PtAppUser">
        insert into PT_APP_USER(
        <include refid="table_columns"/>
        )
        values (
        <include refid="entity_properties"/>
        )
    </insert>

    <select id="get" resultMap="ptAppUserResultMap" parameterType="java.lang.String">
        select
        <include refid="table_columns"/>
        from PT_APP_USER
        where USER_ID = #{id,jdbcType=VARCHAR}
    </select>
    <select id="selectByPrimaryKey" resultMap="ptAppUserResultMap" parameterType="java.lang.String">
        select
        <include refid="table_columns"/>
        from PT_APP_USER
        where 1=1
        <if test="_parameter != null and _parameter !=''">
            and USER_ID = #{_parameter,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="selectByName" resultMap="ptAppUserResultMap" parameterType="java.lang.String">
        select
        <include refid="table_columns"/>
        from PT_APP_USER
        where USER_NAME = #{userName,jdbcType=VARCHAR}
    </select>

    <update id="updateByPrimaryKey" parameterType="com.ruoyi.interfaces.domain.PtAppUser">
        update PT_APP_USER
        <set>
            <if test="userSalt != null and userSalt !=''">
                USER_SALT = #{userSalt,jdbcType=VARCHAR},
            </if>
            <if test="userName != null and userName !=''">
                USER_NAME = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="userPass != null and userPass !=''">
                USER_PASS = #{userPass,jdbcType=VARCHAR},
            </if>
            <if test="userRegdate != null">
                USER_REGDATE = #{userRegdate},
            </if>
            <if test="userType != null and userType !=''">
                USER_TYPE = #{userType,jdbcType=VARCHAR},
            </if>
            <if test="userLastdate != null">
                USER_LASTDATE = #{userLastdate},
            </if>
            <if test="userCount != null and userCount !=''">
                USER_COUNT = #{userCount,jdbcType=VARCHAR},
            </if>
            <if test="userStatus != null and userStatus !=''">
                USER_STATUS = #{userStatus,jdbcType=VARCHAR},
            </if>
            <if test="userPhone != null and userPhone !=''">
                USER_PHONE = #{userPhone,jdbcType=VARCHAR},
            </if>
            <if test="userUnit != null and userUnit !=''">
                USER_UNIT = #{userUnit,jdbcType=VARCHAR},
            </if>
            <if test="userEmail != null and userEmail !=''">
                USER_EMAIL = #{userEmail,jdbcType=VARCHAR},
            </if>
        </set>
        where USER_ID = #{userId,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete
        from PT_APP_USER
        where USER_ID = #{userId,jdbcType=VARCHAR}
    </delete>

</mapper>
