package com.jiayue.ssi.mapper;

import com.jiayue.ssi.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 *  用户管理Mapper
 *
 * @author xsl
 * @since 2023-03-10
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
    /**
     * 通过角色ID查找用户
     *
     * @param roleId 角色ID
     * @return 结果
     */
    public List<SysUser> selectUserByRole(String roleId);
    /**
     * 更改密码
     *
     * @param password 新密码
     * @return 结果
     */
    @Update("update sys_user t set t.password=#{password},t.check_password=#{checkPassword},t.bak_password=#{bakPassword},t.last_update_pwd_time=null where t.id=#{id}")
    public int resetPassword(Long id, String password,String checkPassword,String bakPassword);
    /**
     * 修改审核标识
     *
     * @param signstr 新密码
     * @return 结果
     */
    @Update("update sys_user t set t.signstr=#{signstr} where t.id=#{id}")
    public int updateSignstr(Long id, String signstr);
    /**
     * 修改基本信息
     * @return 结果
     */
    @Update("update sys_user t set t.signstr=#{signstr},t.nickname=#{nickname},t.mailbox=#{mailbox},t.phonenumber=#{phonenumber},t.exp_date=#{exp_date} where t.id=#{id}")
    public int updateBaseInfo(Long id, String signstr, String nickname, String mailbox, String phonenumber, Date exp_date);
}
