StpInterfaceImpl.java 911 Bytes
package vion.interceptor;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.stereotype.Component;
import vion.vo.RoleVO;
import vion.vo.UserVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author HlQ
 * @date 2023/11/28
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
        return userVO.getPermCodeList();
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
        List<RoleVO> roleVOList = userVO.getRoleVOList();
        return roleVOList.stream().map(RoleVO::getCode).collect(Collectors.toList());
    }
}