mirror of https://gitee.com/stylefeng/roses
【8.0】【auth】封装获取当前登录用户获取orgId对应的公司id方法
parent
2057848fab
commit
5b66837d65
|
@ -87,4 +87,12 @@ public interface LoginUserApi {
|
|||
*/
|
||||
boolean getSuperAdminFlag();
|
||||
|
||||
/**
|
||||
* 获取当前登录用户当前机构对应的公司id
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/8/1 14:03
|
||||
*/
|
||||
Long getCurrentUserCompanyId();
|
||||
|
||||
}
|
||||
|
|
|
@ -26,12 +26,15 @@ package cn.stylefeng.roses.kernel.auth.auth;
|
|||
|
||||
import cn.stylefeng.roses.kernel.auth.api.LoginUserApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginUserHolder;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.loginuser.CommonLoginUserUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.sys.api.OrganizationServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -51,6 +54,9 @@ public class LoginUserImpl implements LoginUserApi {
|
|||
@Resource
|
||||
private SysUserServiceApi sysUserServiceApi;
|
||||
|
||||
@Resource
|
||||
private OrganizationServiceApi organizationServiceApi;
|
||||
|
||||
@Override
|
||||
public String getToken() {
|
||||
return CommonLoginUserUtil.getToken();
|
||||
|
@ -122,4 +128,20 @@ public class LoginUserImpl implements LoginUserApi {
|
|||
return sysUserServiceApi.getUserSuperAdminFlag(loginUser.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCurrentUserCompanyId() {
|
||||
|
||||
Long currentOrgId = LoginContext.me().getLoginUser().getCurrentOrgId();
|
||||
if (currentOrgId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CompanyDeptDTO orgCompanyInfo = organizationServiceApi.getOrgCompanyInfo(currentOrgId);
|
||||
if (orgCompanyInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return orgCompanyInfo.getCompanyId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue