feat:清理代码,新版spring支持自动注入,无需手动注入
This commit is contained in:
parent
117ca1e3c4
commit
bc9333db81
@ -104,12 +104,11 @@ public class RestBeanAutoConfigure implements ImportBeanDefinitionRegistrar, Res
|
|||||||
.setUri(makePath(clazz.getSimpleName(), restBean.value()));
|
.setUri(makePath(clazz.getSimpleName(), restBean.value()));
|
||||||
// 分别生成实现类,从repo到controller
|
// 分别生成实现类,从repo到controller
|
||||||
templates.forEach((type, template) -> {
|
templates.forEach((type, template) -> {
|
||||||
Class<?> superClass = superClasses.getOrDefault(type, noOp).apply(restBean);
|
|
||||||
// 当且仅当存在vo时,才编译view-controller
|
// 当且仅当存在vo时,才编译view-controller
|
||||||
if (testNotSupport(superClass, type, hasVo)) {
|
if (testNotSupport(restBean, type, hasVo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
source.setSuperClass(superClass.getCanonicalName());
|
source.setSuperClass(superClasses.getOrDefault(type, noOp).apply(restBean).getCanonicalName());
|
||||||
source.setClassName(clazz.getSimpleName() + type.getName());
|
source.setClassName(clazz.getSimpleName() + type.getName());
|
||||||
try {
|
try {
|
||||||
log.info("尝试注册{}", source.getClassName());
|
log.info("尝试注册{}", source.getClassName());
|
||||||
@ -196,17 +195,18 @@ public class RestBeanAutoConfigure implements ImportBeanDefinitionRegistrar, Res
|
|||||||
/**
|
/**
|
||||||
* 测试是否支持vo
|
* 测试是否支持vo
|
||||||
*
|
*
|
||||||
* @param clazz 父类
|
* @param bean 定义
|
||||||
* @param type 注入类型
|
* @param type 注入类型
|
||||||
* @param hasVo 是否有vo
|
* @param hasVo 是否有vo
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
private boolean testNotSupport(Class<?> clazz, RestBeanCandidate type, boolean hasVo) {
|
private boolean testNotSupport(RestBean bean, RestBeanCandidate type, boolean hasVo) {
|
||||||
|
Class<?> superClass = superClasses.get(REPOSITORY).apply(bean);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VIEW_CONTROLLER:
|
case VIEW_CONTROLLER:
|
||||||
return !hasVo || !DefaultRepository.class.isAssignableFrom(clazz);
|
return !hasVo || !DefaultRepository.class.isAssignableFrom(superClass);
|
||||||
case REACTIVE_VIEW_CONTROLLER:
|
case REACTIVE_VIEW_CONTROLLER:
|
||||||
return !hasVo || !DefaultReactiveRepository.class.isAssignableFrom(clazz);
|
return !hasVo || !DefaultReactiveRepository.class.isAssignableFrom(superClass);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user