package com.agileboot.system.user.mapper;

import com.agileboot.system.user.entity.SysUser;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface SysUserMapper extends BaseMapper<SysUser> {

    Page<SysUser> getUserListByRole(Page<SysUser> objectPage, LambdaQueryWrapper<?> queryWrapper);

    /**
     * 根据条件分页查询用户列表
     *
     * @param page         页码对象
     * @param queryWrapper 查询对象
     * @return 用户信息集合信息
     */
    @Select("SELECT u.*, d.dept_name, d.leader_name as dept_leader "
            + "FROM sys_user u "
            + " LEFT JOIN sys_dept d ON u.dept_id = d.dept_id "
            + "${ew.customSqlSegment}")
    Page<SysUser> getUserList(Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
}
