26 lines
715 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.designhub.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.designhub.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 角色Mapper接口
*/
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
/**
* 根据用户ID查询角色列表
* 从sys_user表的role_ids字段解析角色ID,然后查询角色信息
*/
@Select("SELECT r.* FROM sys_role r " +
"WHERE FIND_IN_SET(r.id, (SELECT role_ids FROM sys_user WHERE id = #{userId})) > 0 " +
"AND r.deleted = 0 AND r.status = 1")
List<Role> selectRolesByUserId(Long userId);
}