mirror of https://gitee.com/stylefeng/roses
【scanner】更新扫描器
parent
98ee4d2484
commit
67b8b81a48
|
@ -1,5 +1,6 @@
|
||||||
package cn.stylefeng.roses.kernel.resource.api.exception;
|
package cn.stylefeng.roses.kernel.resource.api.exception;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.constants.ScannerConstants;
|
import cn.stylefeng.roses.kernel.resource.api.constants.ScannerConstants;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
|
@ -12,16 +13,12 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
*/
|
*/
|
||||||
public class ScannerException extends ServiceException {
|
public class ScannerException extends ServiceException {
|
||||||
|
|
||||||
public ScannerException(String errorCode, String userTip) {
|
|
||||||
super(ScannerConstants.RESOURCE_MODULE_NAME, errorCode, userTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScannerException(AbstractExceptionEnum exception) {
|
public ScannerException(AbstractExceptionEnum exception) {
|
||||||
super(ScannerConstants.RESOURCE_MODULE_NAME, exception);
|
super(ScannerConstants.RESOURCE_MODULE_NAME, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScannerException(AbstractExceptionEnum exception, String userTip) {
|
public ScannerException(AbstractExceptionEnum exception, Object... params) {
|
||||||
super(ScannerConstants.RESOURCE_MODULE_NAME, exception.getErrorCode(), userTip);
|
super(ScannerConstants.RESOURCE_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,7 @@ public class ApiResourceScanner implements BeanPostProcessor {
|
||||||
String className = resourceDefinition.getClassName();
|
String className = resourceDefinition.getClassName();
|
||||||
int controllerIndex = className.indexOf("Controller");
|
int controllerIndex = className.indexOf("Controller");
|
||||||
if (controllerIndex == -1) {
|
if (controllerIndex == -1) {
|
||||||
String userTip = StrUtil.format(ERROR_CONTROLLER_NAME.getUserTip(), controllerClass.getName());
|
throw new ScannerException(ERROR_CONTROLLER_NAME, controllerClass.getName());
|
||||||
throw new ScannerException(ERROR_CONTROLLER_NAME, userTip);
|
|
||||||
}
|
}
|
||||||
String modular = className.substring(0, controllerIndex);
|
String modular = className.substring(0, controllerIndex);
|
||||||
resourceDefinition.setModularCode(modular);
|
resourceDefinition.setModularCode(modular);
|
||||||
|
|
Loading…
Reference in New Issue