<?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.xueyi.system.staff.mapper.DmStaffMapper">

    <resultMap type="DmStaffPo" id="DmStaffResult">
        <result property="userName"      column="user_name"       />
    </resultMap>

    <resultMap type="DmStaffFeature" id="DmStaffFeatureResult">
        <result property="id"      column="id"       />
        <result property="name"      column="name"       />
        <result property="typeId"      column="user_type"       />
        <result property="nickName"      column="nick_name"       />
        <result property="isDel"      column="del_flag"       />
        <result property="syncTime"      column="update_time"       />
        <result property="feature"      column="feature"       />

    </resultMap>

    <select id="selectStaffList" parameterType="DmStaffPo" resultMap="DmStaffResult">
        select * from dm_staff u
    </select>


    <select id="selectStaffFeaturesList" parameterType="DmStaffFeature" resultMap="DmStaffFeatureResult">
            select s.id, s.user_name as name, s.update_time,s.user_type, s.nick_name, s.del_flag, r.feature from dm_staff s  left join dm_resources as r on s.resource_id = r.id
            where (UNIX_TIMESTAMP(s.update_time) * 1000 > #{timestamp} or UNIX_TIMESTAMP(s.create_time) * 1000 > #{timestamp}) and r.feature is not null
    </select>

    <select id="selectVisitorFeaturesList" parameterType="DmStaffFeature" resultMap="DmStaffFeatureResult">
        select s.id, s.name ,s.type as user_type, s.update_time,s.nickname as nick_name, s.del_flag, r.feature from dm_visitors s  left join dm_resources as r on s.resource_id = r.id
        where (UNIX_TIMESTAMP(s.update_time) * 1000 > #{timestamp} or UNIX_TIMESTAMP(s.create_time) * 1000 > #{timestamp} )and r.feature is not null
    </select>
</mapper>