mirror of https://gitee.com/stylefeng/roses
【7.1.6】【scanner】资源扫描修复默认参数的@Validate填值问题
parent
71a920ada8
commit
33804dcc14
|
@ -86,4 +86,8 @@ public interface ScannerConstants {
|
||||||
*/
|
*/
|
||||||
List<String> DONT_PARSE_FIELD = ListUtil.list(false, "serialVersionUID", "delFlag", "createTime", "createUser", "updateTime", "updateUser");
|
List<String> DONT_PARSE_FIELD = ListUtil.list(false, "serialVersionUID", "delFlag", "createTime", "createUser", "updateTime", "updateUser");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用在为validateGroups字段的标识,@Validate注解,不带class类时候的标识
|
||||||
|
*/
|
||||||
|
String DEFAULT_VALIDATED = "default-all";
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.stylefeng.roses.kernel.scanner.api.constants.ScannerConstants.DEFAULT_VALIDATED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 反射工具类,获取方法的一些元数据
|
* 反射工具类,获取方法的一些元数据
|
||||||
*
|
*
|
||||||
|
@ -112,13 +114,15 @@ public class MethodReflectUtil {
|
||||||
Object invoke = validateGroupMethod.invoke(annotation);
|
Object invoke = validateGroupMethod.invoke(annotation);
|
||||||
if (invoke != null) {
|
if (invoke != null) {
|
||||||
Class<?>[] result = (Class<?>[]) invoke;
|
Class<?>[] result = (Class<?>[]) invoke;
|
||||||
|
HashSet<String> groupClassNames = new HashSet<>();
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
HashSet<String> groupClassNames = new HashSet<>();
|
|
||||||
for (Class<?> groupClass : result) {
|
for (Class<?> groupClass : result) {
|
||||||
groupClassNames.add(groupClass.getSimpleName());
|
groupClassNames.add(groupClass.getSimpleName());
|
||||||
}
|
}
|
||||||
return groupClassNames;
|
} else {
|
||||||
|
groupClassNames.add(DEFAULT_VALIDATED);
|
||||||
}
|
}
|
||||||
|
return groupClassNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +63,7 @@ public class SysTimersController {
|
||||||
* @date 2020/6/30 18:26
|
* @date 2020/6/30 18:26
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "添加定时任务", path = "/sysTimers/add")
|
@PostResource(name = "添加定时任务", path = "/sysTimers/add")
|
||||||
public ResponseData<?> add(@RequestBody @Validated(SysTimersParam.add.class) SysTimersParam sysTimersParam) {
|
public ResponseData<?> add(@RequestBody @Valid @Validated(SysTimersParam.add.class) SysTimersParam sysTimersParam) {
|
||||||
sysTimersService.add(sysTimersParam);
|
sysTimersService.add(sysTimersParam);
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue