<?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="cn.bunny.service.mapper.UserMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.bunny.entity.system.user.User">
        <id column="id" property="id"/>
        <result column="nick_name" property="nickName"/>
        <result column="email" property="email"/>
        <result column="password" property="password"/>
        <result column="avatar" property="avatar"/>
        <result column="sex" property="sex"/>
        <result column="person_description" property="personDescription"/>
        <result column="join_time" property="joinTime"/>
        <result column="last_login_time" property="lastLoginTime"/>
        <result column="last_login_ip" property="lastLoginIp"/>
        <result column="last_login_ip_address" property="lastLoginIpAddress"/>
        <result column="total_integral" property="totalIntegral"/>
        <result column="current_integral" property="currentIntegral"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, nick_name, email, password, avatar, sex, person_description, join_time, last_login_time, last_login_ip, last_login_ip_address, total_integral, current_integral, status, create_time, update_time, update_user, is_deleted
    </sql>

    <!-- 后台登录用户 -->
    <select id="login" resultType="cn.bunny.entity.system.user.User">
        select *
        from user
        where (email = #{username} and password = #{password})
           or (nick_name = #{username} and password = #{password})
    </select>
</mapper>
