92 lines
2.7 KiB
Java
92 lines
2.7 KiB
Java
package com.labelsys.backend.mapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.labelsys.backend.entity.SysUser;
|
|
import com.labelsys.backend.enums.UserPosition;
|
|
import com.labelsys.backend.enums.UserRole;
|
|
import com.labelsys.backend.enums.UserStatus;
|
|
import java.util.List;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
/**
|
|
* 用户数据访问层
|
|
*
|
|
* 继承 BaseMapper<SysUser>,提供用户表的基础 CRUD 操作,
|
|
* 并扩展自定义的查询和更新方法。
|
|
*/
|
|
public interface SysUserMapper extends BaseMapper<SysUser> {
|
|
|
|
/**
|
|
* 根据ID和公司ID查询用户
|
|
*
|
|
* @param id 用户ID
|
|
* @param companyId 公司ID
|
|
* @return 用户信息,不存在返回 null
|
|
*/
|
|
SysUser findByIdAndCompanyId(@Param("id") Long id, @Param("companyId") Long companyId);
|
|
|
|
/**
|
|
* 根据公司ID和手机号查询用户
|
|
*
|
|
* @param companyId 公司ID
|
|
* @param phone 手机号
|
|
* @return 用户信息,不存在返回 null
|
|
*/
|
|
SysUser findByCompanyIdAndPhone(@Param("companyId") Long companyId, @Param("phone") String phone);
|
|
|
|
/**
|
|
* 查询公司管理员列表
|
|
*
|
|
* @param companyId 公司ID
|
|
* @return 管理员用户列表
|
|
*/
|
|
List<SysUser> listCompanyAdmins(@Param("companyId") Long companyId);
|
|
|
|
/**
|
|
* 更新用户密码
|
|
*
|
|
* @param id 用户ID
|
|
* @param companyId 公司ID
|
|
* @param passwordHash 加密后的密码
|
|
* @param mustChangePassword 是否强制修改密码
|
|
* @return 更新影响的行数
|
|
*/
|
|
int updatePassword(@Param("id") Long id, @Param("companyId") Long companyId,
|
|
@Param("passwordHash") String passwordHash, @Param("mustChangePassword") boolean mustChangePassword);
|
|
|
|
/**
|
|
* 更新用户角色和岗位
|
|
*
|
|
* @param id 用户ID
|
|
* @param companyId 公司ID
|
|
* @param role 角色
|
|
* @param position 岗位
|
|
* @return 更新影响的行数
|
|
*/
|
|
int updateAssignment(@Param("id") Long id, @Param("companyId") Long companyId, @Param("role") UserRole role,
|
|
@Param("position") UserPosition position);
|
|
|
|
/**
|
|
* 更新用户状态
|
|
*
|
|
* @param id 用户ID
|
|
* @param companyId 公司ID
|
|
* @param status 用户状态
|
|
* @return 更新影响的行数
|
|
*/
|
|
int updateStatus(@Param("id") Long id, @Param("companyId") Long companyId, @Param("status") UserStatus status);
|
|
|
|
/**
|
|
* 增加会话版本号
|
|
*
|
|
* @param id 用户ID
|
|
* @param companyId 公司ID
|
|
* @return 更新影响的行数
|
|
*/
|
|
int bumpSessionVersion(@Param("id") Long id, @Param("companyId") Long companyId);
|
|
|
|
/**
|
|
* 删除所有用户(测试用)
|
|
*/
|
|
void deleteAll();
|
|
} |