<?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.fzm.mall.server.admin.home_page.dao.AdminMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.home_page.model.Admin">
        <id column="id" property="id"/>
        <result column="admin_id" property="adminId"/>
        <result column="merchant_id" property="merchantId"/>
        <result column="role_id" property="roleId"/>
        <result column="head_img" property="headImg"/>
        <result column="account" property="account"/>
        <result column="password" property="password"/>
        <result column="user" property="user"/>
        <result column="link_phone" property="linkPhone"/>
        <result column="type" property="type"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.home_page.entity.vo.AdminVO">
        SELECT
        A.admin_id,A.account,A.password,A.role_id,R.role_name,A.user,A.link_phone,A.create_time,A.status
        FROM
        admin A
        LEFT JOIN
        admin_role R
        ON
        A.role_id = R.role_id
        <where>
            <if test="uid!=null and uid!=''">
                A.admin_id = #{uid}
            </if>
            <if test="account!=null and account!=''">
                AND
                A.account = #{account}
            </if>
            AND
            A.status != 0
            AND
            A.admin_id != #{loginAdminId}
            AND
            A.merchant_id = #{merchantId}
        </where>
        ORDER BY
        A.create_time
        DESC
    </select>
</mapper>
