chore: continew-starter 2.7.4 => 2.7.5

1.BaseServiceImpl 所在包调整
2.BaseController 改为在 Admin common 模块编写(重构权限校验 checkPermission 处理)
3.CRUD ValidateGroup => CrudValidationGroup
4.Admin ValidateGroup => ValidationGroup
5.修复 Query 查询数组范围报错

Closes #IB8711
This commit is contained in:
2024-12-06 22:06:23 +08:00
parent 61fe39d439
commit d7ae7b4e42
33 changed files with 153 additions and 116 deletions

View File

@@ -33,7 +33,7 @@ import top.continew.admin.open.model.resp.AppResp;
import top.continew.admin.open.model.resp.AppSecretResp;
import top.continew.admin.open.service.AppService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**

View File

@@ -63,7 +63,7 @@ public class DemoEnvironmentJob {
private static final Long MESSAGE_FLAG = 0L;
private static final Long[] USER_FLAG = {1L, 547889293968801831L};
private static final Long ROLE_FLAG = 547888897925840928L;
private static final Long MENU_FLAG = 10003L;
private static final Long MENU_FLAG = 10000L;
private static final Long DEPT_FLAG = 547888580614160409L;
/**

View File

@@ -30,7 +30,7 @@ import top.continew.admin.schedule.model.req.JobStatusReq;
import top.continew.admin.schedule.model.resp.JobResp;
import top.continew.admin.schedule.service.JobService;
import top.continew.starter.extension.crud.model.resp.PageResp;
import top.continew.starter.extension.crud.util.ValidateGroup;
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
import top.continew.starter.log.core.annotation.Log;
import java.util.List;
@@ -61,7 +61,7 @@ public class JobController {
@Operation(summary = "新增任务", description = "新增任务")
@SaCheckPermission("schedule:job:add")
@PostMapping
public void add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody JobReq req) {
public void add(@Validated(CrudValidationGroup.Add.class) @RequestBody JobReq req) {
baseService.add(req);
}
@@ -69,7 +69,7 @@ public class JobController {
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
@SaCheckPermission("schedule:job:update")
@PutMapping("/{id}")
public void update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody JobReq req, @PathVariable Long id) {
public void update(@Validated(CrudValidationGroup.Update.class) @RequestBody JobReq req, @PathVariable Long id) {
baseService.update(req, id);
}

View File

@@ -18,12 +18,12 @@ package top.continew.admin.controller.system;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
import top.continew.admin.common.base.BaseController;
import top.continew.admin.system.model.query.DeptQuery;
import top.continew.admin.system.model.req.DeptReq;
import top.continew.admin.system.model.resp.DeptResp;
import top.continew.admin.system.service.DeptService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**

View File

@@ -23,7 +23,7 @@ import top.continew.admin.system.model.req.DictReq;
import top.continew.admin.system.model.resp.DictResp;
import top.continew.admin.system.service.DictService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**

View File

@@ -23,7 +23,7 @@ import top.continew.admin.system.model.req.DictItemReq;
import top.continew.admin.system.model.resp.DictItemResp;
import top.continew.admin.system.service.DictItemService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.log.core.annotation.Log;

View File

@@ -27,7 +27,7 @@ import top.continew.admin.system.model.resp.FileResp;
import top.continew.admin.system.model.resp.FileStatisticsResp;
import top.continew.admin.system.service.FileService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.log.core.annotation.Log;

View File

@@ -19,10 +19,8 @@ package top.continew.admin.controller.system;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.continew.admin.common.base.BaseController;
import top.continew.admin.system.model.query.MenuQuery;
import top.continew.admin.system.model.req.MenuReq;
import top.continew.admin.system.model.resp.MenuResp;
@@ -30,11 +28,11 @@ import top.continew.admin.system.service.MenuService;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.core.util.URLUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudApi;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.util.ValidateGroup;
import java.lang.reflect.Method;
/**
* 菜单管理 API
@@ -48,23 +46,13 @@ import top.continew.starter.extension.crud.util.ValidateGroup;
public class MenuController extends BaseController<MenuService, MenuResp, MenuResp, MenuQuery, MenuReq> {
@Override
public BaseIdResp<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody MenuReq req) {
this.checkPath(req);
return super.add(req);
}
@Override
public void update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody MenuReq req, @PathVariable Long id) {
this.checkPath(req);
super.update(req, id);
}
/**
* 检查路由地址格式
*
* @param req 创建或修改参数
*/
private void checkPath(MenuReq req) {
public void preHandle(CrudApi crudApi, Object[] args, Method targetMethod, Class<?> targetClass) throws Exception {
super.preHandle(crudApi, args, targetMethod, targetClass);
Api api = crudApi.value();
if (!(Api.ADD.equals(api) || Api.UPDATE.equals(api))) {
return;
}
MenuReq req = (MenuReq)args[0];
Boolean isExternal = ObjectUtil.defaultIfNull(req.getIsExternal(), false);
String path = req.getPath();
ValidationUtils.throwIf(Boolean.TRUE.equals(isExternal) && !URLUtils

View File

@@ -17,10 +17,8 @@
package top.continew.admin.controller.system;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.continew.admin.common.base.BaseController;
import top.continew.admin.system.enums.NoticeScopeEnum;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.req.NoticeReq;
@@ -28,12 +26,11 @@ import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.service.NoticeService;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudApi;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.util.ValidateGroup;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
/**
@@ -48,23 +45,13 @@ import java.time.LocalDateTime;
public class NoticeController extends BaseController<NoticeService, NoticeResp, NoticeDetailResp, NoticeQuery, NoticeReq> {
@Override
public BaseIdResp<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody NoticeReq req) {
this.check(req);
return super.add(req);
}
@Override
public void update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody NoticeReq req, @PathVariable Long id) {
this.check(req);
super.update(req, id);
}
/**
* 校验
*
* @param req 创建或修改参数
*/
private void check(NoticeReq req) {
public void preHandle(CrudApi crudApi, Object[] args, Method targetMethod, Class<?> targetClass) throws Exception {
super.preHandle(crudApi, args, targetMethod, targetClass);
Api api = crudApi.value();
if (!(Api.ADD.equals(api) || Api.UPDATE.equals(api))) {
return;
}
NoticeReq req = (NoticeReq)args[0];
// 校验生效时间
LocalDateTime effectiveTime = req.getEffectiveTime();
LocalDateTime terminateTime = req.getTerminateTime();

View File

@@ -34,7 +34,7 @@ import top.continew.admin.system.model.resp.RoleResp;
import top.continew.admin.system.service.RoleService;
import top.continew.admin.system.service.UserRoleService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import java.util.List;

View File

@@ -23,7 +23,7 @@ import top.continew.admin.system.model.req.StorageReq;
import top.continew.admin.system.model.resp.StorageResp;
import top.continew.admin.system.service.StorageService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**

View File

@@ -44,10 +44,10 @@ import top.continew.admin.system.service.UserService;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.util.ValidateGroup;
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
import java.io.IOException;
@@ -68,7 +68,7 @@ public class UserController extends BaseController<UserService, UserResp, UserDe
private final UserService userService;
@Override
public BaseIdResp<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody UserReq req) {
public BaseIdResp<Long> add(@Validated(CrudValidationGroup.Add.class) @RequestBody UserReq req) {
String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword()));
ValidationUtils.throwIfNull(rawPassword, "密码解密失败");
ValidationUtils.throwIf(!ReUtil

View File

@@ -5,5 +5,5 @@
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
:: ${project.name} :: v${project.version}
:: ContiNew Starter :: v2.7.4
:: ContiNew Starter :: v2.7.5
:: Spring Boot :: v${spring-boot.version}