feat:优化鉴权实体,增加用户权限标记

This commit is contained in:
wangyu 2021-12-04 11:26:34 +08:00
parent 1cc68d21b4
commit d4d80d2d55

View File

@ -3,6 +3,7 @@ package com.flyfish.framework.domain.authorized;
import com.flyfish.framework.context.UserContext;
import com.flyfish.framework.domain.base.AuditDomain;
import com.flyfish.framework.domain.po.User;
import com.flyfish.framework.exception.biz.InvalidBusinessException;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
@ -19,8 +20,11 @@ public abstract class AuthorizedDomain extends AuditDomain {
if (StringUtils.isNotBlank(authorizeId)) {
return authorizeId;
} else {
return UserContext.sharedContext().map(UserContext::currentUser)
.map(User::getAuthority).orElse(null);
return UserContext.sharedContext()
.map(UserContext::currentUser)
.map(User::getAuthority)
.filter(StringUtils::isNotBlank)
.orElseThrow(() -> new InvalidBusinessException("您尚未选择所在部门!请确认您使用的部门身份!"));
}
}
}