<?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.ssm.manage.mapper.StaffLoginRecordingMapper">

    <resultMap id="BaseResultMap" type="com.ssm.manage.entity.StaffLoginRecording">
        <result property="id" column="id"/>
        <result property="staffId" column="staff_id"/>
        <result property="staffName" column="staff_name"/>
        <result property="loginTime" column="login_time"/>
        <result property="massage" column="massage"/>
        <result property="loginType" column="login_type"/>
        <result property="mobilePhone" column="mobile_phone"/>
        <result property="state" column="state"/>
    </resultMap>

    <sql id="Base_Column_List">
        id , staff_id, staff_name, login_time, massage, login_type , mobile_phone ,state
    </sql>
    <insert id="save" parameterType="com.ssm.manage.entity.StaffLoginRecording">
        insert into staff_login_recording_${tab} (id,staff_id,staff_name,login_time,massage,login_type,mobile_phone,state)
        values (#{id},#{staffId},#{staffName},#{loginTime},#{massage},#{loginType},#{mobilePhone},#{state})
    </insert>
    <update id="updateById">
        update staff_login_recording_${tab} set <if test="staffId != null">
         staff_id = #{staffId},
    </if>
        <if test="staffName != null and staffName != ''">
             staff_name = #{staffName},
        </if>
        <if test="loginTime != null">
             login_time = #{loginTime},
        </if>
        <if test="massage != null and massage != ''">
             massage = #{massage},
        </if>
        <if test="loginType != null">
             login_type = #{loginType},
        </if>
        <if test="mobilePhone != null">
             mobile_phone = #{mobilePhone},
        </if>
        <if test="state != null">
             state = #{state}
        </if>
where id = #{id}
    </update>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from staff_login_recording
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="staffId != null">
                and staff_id = #{staffId}
            </if>
            <if test="staffName != null and staffName != ''">
                and staff_name = #{staffName}
            </if>
            <if test="loginTime != null">
                and login_time = #{loginTime}
            </if>
            <if test="massage != null and massage != ''">
                and massage = #{massage}
            </if>
            <if test="loginType != null">
                and login_type = #{loginType}
            </if>
            <if test="mobilePhone != null">
                and mobile_phone = #{mobilePhone}
            </if>
           <if test="state != null">
                and state = #{state}
            </if>
        </where>
    </select>

    <select id="createTable" parameterType="java.lang.String">
        create table IF NOT EXISTS staff_login_recording_${tab} like staff_login_recording
    </select>
</mapper>
