框架调整
This commit is contained in:
parent
b62dba7be0
commit
e6d5a0ed1d
@ -16,35 +16,43 @@ import java.util.TimeZone;
|
||||
public class EbikeTenantFactory implements TenantFactory {
|
||||
|
||||
public Object[] getTenantIds() {
|
||||
if (StpUtil.isLogin()) {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
Object attribute = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
||||
if (attribute != null) {
|
||||
String id = (String) StpUtil.getLoginId();
|
||||
Object object = StpUtil.getSessionByLoginId(id).get(id);
|
||||
ObjectMapper objectMapper = new ObjectMapper()
|
||||
.registerModule(new JavaTimeModule())
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
CommonStaffInfo staffInfo = objectMapper.convertValue(object, CommonStaffInfo.class);
|
||||
List<CommonEbikeRole> roles = staffInfo.getRoles();
|
||||
boolean isSysAdmin = false;
|
||||
for (CommonEbikeRole role : roles) {
|
||||
if (role.getSysAdmin()) {
|
||||
isSysAdmin = true;
|
||||
break;
|
||||
try {
|
||||
if (StpUtil.isLogin()) {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
if (attributes != null) {
|
||||
Object attribute = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
||||
String id = (String) StpUtil.getLoginId();
|
||||
Object object = StpUtil.getSessionByLoginId(id).get(id);
|
||||
ObjectMapper objectMapper = new ObjectMapper()
|
||||
.registerModule(new JavaTimeModule())
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
CommonStaffInfo staffInfo = objectMapper.convertValue(object, CommonStaffInfo.class);
|
||||
List<CommonEbikeRole> roles = staffInfo.getRoles();
|
||||
boolean isSysAdmin = false;
|
||||
for (CommonEbikeRole role : roles) {
|
||||
if (role.getSysAdmin()) {
|
||||
isSysAdmin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
long tenantId = 0;
|
||||
if (attribute != null) {
|
||||
tenantId = Long.parseLong(attribute.toString());
|
||||
}
|
||||
//系统管理员
|
||||
if (isSysAdmin) {
|
||||
return null;
|
||||
} else {
|
||||
return new Object[]{tenantId};
|
||||
}
|
||||
}
|
||||
long tenantId = Long.parseLong(attribute.toString());
|
||||
//系统管理员
|
||||
if (isSysAdmin) {
|
||||
return null;
|
||||
} else {
|
||||
return new Object[]{tenantId};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user