com.zznote.basecommon.common.config.satoken.StpInterfaceImpl Maven / Gradle / Ivy
The newest version!
package com.zznote.basecommon.common.config.satoken;
import cn.dev33.satoken.stp.StpInterface;
import com.zznote.basecommon.common.enums.UserType;
import com.zznote.basecommon.common.util.LoginHelper;
import com.zznote.basecommon.dto.LoginUser;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义权限验证接口扩展
* @Author: zhangzhen
* @Date: create in 2022/4/12 10:32 上午
*/
@Component
public class StpInterfaceImpl implements StpInterface {
/**
* 返回一个账号所拥有的权限码集合
*/
@Override
public List getPermissionList(Object loginId, String loginType) {
LoginUser loginUser = LoginHelper.getLoginUser();
UserType userType = UserType.getUserType(loginUser.getUserType());
if (userType == UserType.T_USER) {
return new ArrayList<>(loginUser.getMenuPermission());
} else if (userType == UserType.APP_USER) {
// 其他端 自行根据业务编写
}
return new ArrayList<>();
}
/**
* 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
*/
@Override
public List getRoleList(Object loginId, String loginType) {
LoginUser loginUser = LoginHelper.getLoginUser();
UserType userType = UserType.getUserType(loginUser.getUserType());
if (userType == UserType.T_USER) {
return new ArrayList<>(loginUser.getRolePermission());
} else if (userType == UserType.APP_USER) {
// 其他端 自行根据业务编写
}
return new ArrayList<>();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy