id数据类型调整

This commit is contained in:
2025-10-30 11:05:07 +08:00
parent 3e3e496762
commit 829e9012cc

View File

@@ -0,0 +1,78 @@
package com.sdm.system.config;
import com.sdm.system.service.ISysUserService;
import com.sdm.system.service.ISysRoleService;
import com.sdm.system.service.ISysTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
@Configuration
public class ServiceConfig {
@Value("${system.useCidSwitch:false}")
private boolean useCidSwitch;
@Value("${userSystem.cidUser:cid}")
private String cidUserType;
@Value("${userSystem.localUser:local}")
private String localUserType;
@Value("${roleSystem.cidRole:cid}")
private String cidRoleType;
@Value("${roleSystem.localRole:local}")
private String localRoleType;
@Value("${tenantSystem.cidTenant:cid}")
private String cidTenantType;
@Value("${tenantSystem.localTenant:local}")
private String localTenantType;
@Autowired
private List<ISysUserService> userServices;
@Autowired
private List<ISysRoleService> roleServices;
@Autowired
private List<ISysTenantService> tenantServices;
@Bean
public ISysUserService userService() {
String userType = useCidSwitch ? cidUserType : localUserType;
return userServices.stream()
.filter(service -> service.getType().equals(userType))
.findFirst()
.orElseThrow(() -> new IllegalStateException(
"No userService found for type: " + userType
));
}
@Bean
public ISysRoleService roleService() {
String roleType = useCidSwitch ? cidRoleType : localRoleType;
return roleServices.stream()
.filter(service -> service.getType().equals(roleType))
.findFirst()
.orElseThrow(() -> new IllegalStateException(
"No roleService found for type: " + roleType
));
}
@Bean
public ISysTenantService tenantService() {
String tenantType = useCidSwitch ? cidTenantType : localTenantType;
return tenantServices.stream()
.filter(service -> service.getType().equals(tenantType))
.findFirst()
.orElseThrow(() -> new IllegalStateException(
"No tenantService found for type: " + tenantType
));
}
}