mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 08:57:17 +08:00
refactor(extension/crud): 优化部分代码
This commit is contained in:
@@ -33,7 +33,7 @@ import top.continew.starter.extension.crud.model.req.BaseReq;
|
||||
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
|
||||
import top.continew.starter.extension.crud.model.resp.BasePageResp;
|
||||
import top.continew.starter.extension.crud.service.BaseService;
|
||||
import top.continew.starter.extension.crud.util.ValidateGroup;
|
||||
import top.continew.starter.extension.crud.validation.CrudValidateGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.util.List;
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <C> 创建或修改类型
|
||||
* @param <C> 创建或修改参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
|
||||
@Operation(summary = "新增数据", description = "新增数据")
|
||||
@ResponseBody
|
||||
@PostMapping
|
||||
public BaseIdResp<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody C req) {
|
||||
public BaseIdResp<Long> add(@Validated(CrudValidateGroup.Add.class) @RequestBody C req) {
|
||||
return new BaseIdResp<>(baseService.add(req));
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@ResponseBody
|
||||
@PutMapping("/{id}")
|
||||
public void update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody C req, @PathVariable("id") Long id) {
|
||||
public void update(@Validated(CrudValidateGroup.Update.class) @RequestBody C req, @PathVariable("id") Long id) {
|
||||
baseService.update(req, id);
|
||||
}
|
||||
|
||||
|
@@ -60,11 +60,11 @@ public final class CrudApiStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除一个注解处理器
|
||||
* 移除一个处理器
|
||||
*
|
||||
* @param controllerClass 控制器类
|
||||
*/
|
||||
public void removeAnnotationHandler(Class<?> controllerClass) {
|
||||
public void removeHandler(Class<?> controllerClass) {
|
||||
handlerMap.remove(controllerClass);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <C> 创建或修改类型
|
||||
* @param <C> 创建或修改参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@@ -14,30 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.extension.crud.util;
|
||||
package top.continew.starter.extension.crud.validation;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 分组校验
|
||||
* CRUD 分组校验
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface ValidateGroup extends Default {
|
||||
public interface CrudValidateGroup extends Default {
|
||||
|
||||
/**
|
||||
* 分组校验-增删改查
|
||||
* CRUD 分组校验-新增
|
||||
*/
|
||||
interface Crud extends ValidateGroup {
|
||||
/**
|
||||
* 分组校验-创建
|
||||
*/
|
||||
interface Add extends Crud {}
|
||||
interface Add extends CrudValidateGroup {}
|
||||
|
||||
/**
|
||||
* 分组校验-修改
|
||||
*/
|
||||
interface Update extends Crud {}
|
||||
}
|
||||
/**
|
||||
* CRUD 分组校验-修改
|
||||
*/
|
||||
interface Update extends CrudValidateGroup {}
|
||||
}
|
@@ -59,7 +59,7 @@ import java.util.Optional;
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <C> 创建或修改类型
|
||||
* @param <C> 创建或修改参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@@ -64,7 +64,7 @@ import java.util.*;
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <C> 创建或修改类型
|
||||
* @param <C> 创建或修改参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
Reference in New Issue
Block a user