package com.user.service.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.orbit.domain.enity.SysUser;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 通过用户ID查询用户
     *
     * @param userId 用户ID
     * @return 用户对象信息
     */
    public SysUser selectUserById(Long userId);

    /**
     * 修改用户信息
     *
     * @param user 用户信息
     * @return 结果
     */
    public int updateUser(SysUser user);

    /**
     * 批量删除用户信息
     *
     * @param userIds 需要删除的用户ID
     * @return 结果
     */
    public int deleteUserByIds(Long[] userIds);

    /**
     * 通过用户名查询用户
     *
     * @param userName 用户名
     * @return 用户对象信息
     */
    public SysUser selectUserByUserName(String userName);
    /**
     * 校验用户名称是否唯一
     *
     * @param userName 用户名称
     * @return 结果
     */
    @Select("<script>" +
            "select " +
            " count(1) " +
            " from " +
            " sys_user " +
            " where " +
            " user_name=#{userName} " +
            " limit 1 " +
            "</script>"
    )
    public int checkUserNameUnique(String userName);

    /**
     * 校验手机号码是否唯一
     *
     * @param phonenumber 手机号码
     * @return 结果
     */
    @Select("<script>" +
            "select " +
            " count(1) " +
            " from " +
            " sys_user " +
            " where " +
            " phone_number=#{phoneNumber} " +
            " limit 1 " +
            "</script>"
    )
    public SysUser checkPhoneUnique(String phonenumber);

    /**
     * 校验email是否唯一
     *
     * @param email 用户邮箱
     * @return 结果
     */
    @Select("<script>" +
            "select " +
            " count(1) " +
            " from " +
            " sys_user " +
            " where " +
            " email=#{email} " +
            " limit 1 " +
            "</script>"
    )
    public SysUser checkEmailUnique(String email);


    public List<SysUser> selectUserByVo(SysUser vo);

    /**
     * 重写添加方法:用于获取插入后获取id
     * @param sysUser  用户信息
     * @return
     */
    public int add(SysUser sysUser);


}
