框架调整
This commit is contained in:
parent
b62dba7be0
commit
e6d5a0ed1d
@ -16,35 +16,43 @@ import java.util.TimeZone;
|
|||||||
public class EbikeTenantFactory implements TenantFactory {
|
public class EbikeTenantFactory implements TenantFactory {
|
||||||
|
|
||||||
public Object[] getTenantIds() {
|
public Object[] getTenantIds() {
|
||||||
if (StpUtil.isLogin()) {
|
try {
|
||||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
if (StpUtil.isLogin()) {
|
||||||
Object attribute = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||||
if (attribute != null) {
|
if (attributes != null) {
|
||||||
String id = (String) StpUtil.getLoginId();
|
Object attribute = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
||||||
Object object = StpUtil.getSessionByLoginId(id).get(id);
|
String id = (String) StpUtil.getLoginId();
|
||||||
ObjectMapper objectMapper = new ObjectMapper()
|
Object object = StpUtil.getSessionByLoginId(id).get(id);
|
||||||
.registerModule(new JavaTimeModule())
|
ObjectMapper objectMapper = new ObjectMapper()
|
||||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
.registerModule(new JavaTimeModule())
|
||||||
.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||||
CommonStaffInfo staffInfo = objectMapper.convertValue(object, CommonStaffInfo.class);
|
.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||||
List<CommonEbikeRole> roles = staffInfo.getRoles();
|
CommonStaffInfo staffInfo = objectMapper.convertValue(object, CommonStaffInfo.class);
|
||||||
boolean isSysAdmin = false;
|
List<CommonEbikeRole> roles = staffInfo.getRoles();
|
||||||
for (CommonEbikeRole role : roles) {
|
boolean isSysAdmin = false;
|
||||||
if (role.getSysAdmin()) {
|
for (CommonEbikeRole role : roles) {
|
||||||
isSysAdmin = true;
|
if (role.getSysAdmin()) {
|
||||||
break;
|
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