package com.storlead.system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.storlead.system.pojo.entity.UserRoleEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户角色表 Mapper 接口
 * </p>
 *
 * @Author scott
 * @since 2018-12-21
 */
public interface UserRoleMapper extends BaseMapper<UserRoleEntity> {

    @Select("select name from role r left join user_role ur on u.user_id = r.id left join user u on u.id = ur.user_id where u.user_name = #{username}")
    List<String> getRoleByUsername(String username);

    /**
     * 初始化没有角色的用户 给 roleID = 2 普通用户
     * @date 2021-4-14 下午 2:13
     */
    long initUserRole();


    List<UserRoleEntity> selectUserRole(@Param(Constants.WRAPPER) Wrapper<UserRoleEntity> wrapper);
}
