From d7ae7b4e42c424a3db51c72a0ed79572c9fd7601 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Fri, 6 Dec 2024 22:06:23 +0800 Subject: [PATCH] chore: continew-starter 2.7.4 => 2.7.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.BaseServiceImpl 所在包调整 2.BaseController 改为在 Admin common 模块编写(重构权限校验 checkPermission 处理) 3.CRUD ValidateGroup => CrudValidationGroup 4.Admin ValidateGroup => ValidationGroup 5.修复 Query 查询数组范围报错 Closes #IB8711 --- README.md | 4 +- continew-common/pom.xml | 42 +++++------- .../admin/common/base/BaseController.java | 68 +++++++++++++++++++ .../admin/system/model/req/StorageReq.java | 12 ++-- .../model/req/user/UserImportRowReq.java | 4 +- .../admin/system/model/req/user/UserReq.java | 4 +- .../system/service/impl/DeptServiceImpl.java | 2 +- .../service/impl/DictItemServiceImpl.java | 2 +- .../system/service/impl/DictServiceImpl.java | 2 +- .../system/service/impl/FileServiceImpl.java | 2 +- .../system/service/impl/MenuServiceImpl.java | 2 +- .../service/impl/NoticeServiceImpl.java | 2 +- .../system/service/impl/RoleServiceImpl.java | 2 +- .../service/impl/StorageServiceImpl.java | 8 +-- .../system/service/impl/UserServiceImpl.java | 2 +- .../ValidationGroup.java} | 6 +- .../templates/backend/Controller.ftl | 2 +- .../templates/backend/ServiceImpl.ftl | 2 +- .../open/service/impl/AppServiceImpl.java | 2 +- .../admin/controller/open/AppController.java | 2 +- .../schedule/DemoEnvironmentJob.java | 2 +- .../controller/schedule/JobController.java | 6 +- .../controller/system/DeptController.java | 2 +- .../controller/system/DictController.java | 2 +- .../controller/system/DictItemController.java | 2 +- .../controller/system/FileController.java | 2 +- .../controller/system/MenuController.java | 34 +++------- .../controller/system/NoticeController.java | 33 +++------ .../controller/system/RoleController.java | 2 +- .../controller/system/StorageController.java | 2 +- .../controller/system/UserController.java | 6 +- continew-webapi/src/main/resources/banner.txt | 2 +- pom.xml | 2 +- 33 files changed, 153 insertions(+), 116 deletions(-) create mode 100644 continew-common/src/main/java/top/continew/admin/common/base/BaseController.java rename continew-module-system/src/main/java/top/continew/admin/system/{util/ValidateGroup.java => validation/ValidationGroup.java} (87%) diff --git a/README.md b/README.md index a853fa28..f785ff83 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Sonar Status -ContiNew Starter +ContiNew Starter Spring Boot @@ -225,7 +225,7 @@ public class DeptController extends BaseControllerArco Design | 2.56.0 | 字节跳动推出的前端 UI 框架,年轻化的色彩和组件设计。 | | TypeScript | 5.0.4 | TypeScript 是微软开发的一个开源的编程语言,通过在 JavaScript 的基础上添加静态类型定义构建而成。 | | Vite | 5.1.5 | 下一代的前端工具链,为开发提供极速响应。 | -| [ContiNew Starter](https://github.com/continew-org/continew-starter) | 2.7.4 | ContiNew Starter 包含了一系列经过企业实践优化的依赖包(如 MyBatis-Plus、SaToken),可轻松集成到应用中,为开发人员减少手动引入依赖及配置的麻烦,为 Spring Boot Web 项目的灵活快速构建提供支持。 | +| [ContiNew Starter](https://github.com/continew-org/continew-starter) | 2.7.5 | ContiNew Starter 包含了一系列经过企业实践优化的依赖包(如 MyBatis-Plus、SaToken),可轻松集成到应用中,为开发人员减少手动引入依赖及配置的麻烦,为 Spring Boot Web 项目的灵活快速构建提供支持。 | | Spring Boot | 3.2.10 | 简化 Spring 应用的初始搭建和开发过程,基于“约定优于配置”的理念,使开发人员不再需要定义样板化的配置。(Spring Boot 3.0 开始,要求 Java 17 作为最低版本) | | Undertow | 2.3.13.Final | 采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制。 | | Sa-Token + JWT | 1.39.0 | 轻量级 Java 权限认证框架,让鉴权变得简单、优雅。 | diff --git a/continew-common/pom.xml b/continew-common/pom.xml index bcf7dd48..9d4246bd 100644 --- a/continew-common/pom.xml +++ b/continew-common/pom.xml @@ -58,30 +58,36 @@ continew-starter-extension-crud-mp + + + top.continew + continew-starter-auth-satoken + + + org.springframework.boot + spring-boot-starter-web + + + + top.continew continew-starter-auth-justauth - - - top.continew - continew-starter-extension-datapermission-mp - - - - - top.continew - continew-starter-data-mp - - top.continew continew-starter-cache-jetcache + + + top.continew + continew-starter-extension-datapermission-mp + + top.continew @@ -112,12 +118,6 @@ continew-starter-captcha-behavior - - - top.continew - continew-starter-file-excel - - top.continew @@ -142,12 +142,6 @@ continew-starter-security-password - - - top.continew - continew-starter-api-doc - - top.continew diff --git a/continew-common/src/main/java/top/continew/admin/common/base/BaseController.java b/continew-common/src/main/java/top/continew/admin/common/base/BaseController.java new file mode 100644 index 00000000..09e25c67 --- /dev/null +++ b/continew-common/src/main/java/top/continew/admin/common/base/BaseController.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.continew.admin.common.base; + +import cn.dev33.satoken.annotation.SaIgnore; +import cn.dev33.satoken.context.SaHolder; +import cn.dev33.satoken.context.model.SaRequest; +import cn.dev33.satoken.sign.SaSignTemplate; +import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.annotation.AnnotationUtil; +import cn.hutool.core.text.CharSequenceUtil; +import top.continew.starter.core.constant.StringConstants; +import top.continew.starter.extension.crud.annotation.CrudApi; +import top.continew.starter.extension.crud.annotation.CrudRequestMapping; +import top.continew.starter.extension.crud.controller.AbstractBaseController; +import top.continew.starter.extension.crud.enums.Api; +import top.continew.starter.extension.crud.model.req.BaseReq; +import top.continew.starter.extension.crud.service.BaseService; + +import java.lang.reflect.Method; +import java.util.List; + +/** + * 控制器基类 + * + * @param 业务接口 + * @param 列表类型 + * @param 详情类型 + * @param 查询条件 + * @param 创建或修改参数类型 + * @author Charles7c + * @since 2024/12/6 20:30 + */ +public class BaseController, L, D, Q, C extends BaseReq> extends AbstractBaseController { + + @Override + public void preHandle(CrudApi crudApi, Object[] args, Method targetMethod, Class targetClass) throws Exception { + SaRequest saRequest = SaHolder.getRequest(); + List paramNames = saRequest.getParamNames(); + if (paramNames.stream().anyMatch(SaSignTemplate.sign::equals)) { + return; + } + if (AnnotationUtil.hasAnnotation(targetMethod, SaIgnore.class) || AnnotationUtil + .hasAnnotation(targetClass, SaIgnore.class)) { + return; + } + CrudRequestMapping crudRequestMapping = targetClass.getDeclaredAnnotation(CrudRequestMapping.class); + String path = crudRequestMapping.value(); + String prefix = String.join(StringConstants.COLON, CharSequenceUtil.splitTrim(path, StringConstants.SLASH)); + Api api = crudApi.value(); + String apiName = Api.PAGE.equals(api) || Api.TREE.equals(api) ? Api.LIST.name() : api.name(); + StpUtil.checkPermission("%s:%s".formatted(prefix, apiName.toLowerCase())); + } +} diff --git a/continew-module-system/src/main/java/top/continew/admin/system/model/req/StorageReq.java b/continew-module-system/src/main/java/top/continew/admin/system/model/req/StorageReq.java index 3590eaa7..e5c71fbd 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/model/req/StorageReq.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/model/req/StorageReq.java @@ -25,7 +25,7 @@ import org.hibernate.validator.constraints.Length; import top.continew.admin.common.constant.RegexConstants; import top.continew.admin.common.enums.DisEnableStatusEnum; import top.continew.admin.system.enums.StorageTypeEnum; -import top.continew.admin.system.util.ValidateGroup; +import top.continew.admin.system.validation.ValidationGroup; import top.continew.starter.extension.crud.model.req.BaseReq; import java.io.Serial; @@ -71,14 +71,14 @@ public class StorageReq extends BaseReq { */ @Schema(description = "访问密钥", example = "") @Length(max = 255, message = "访问密钥长度不能超过 {max} 个字符") - @NotBlank(message = "访问密钥不能为空", groups = ValidateGroup.Storage.S3.class) + @NotBlank(message = "访问密钥不能为空", groups = ValidationGroup.Storage.S3.class) private String accessKey; /** * 私有密钥 */ @Schema(description = "私有密钥", example = "") - @NotBlank(message = "私有密钥不能为空", groups = ValidateGroup.Storage.S3.class) + @NotBlank(message = "私有密钥不能为空", groups = ValidationGroup.Storage.S3.class) private String secretKey; /** @@ -86,7 +86,7 @@ public class StorageReq extends BaseReq { */ @Schema(description = "终端节点", example = "") @Length(max = 255, message = "终端节点长度不能超过 {max} 个字符") - @NotBlank(message = "终端节点不能为空", groups = ValidateGroup.Storage.S3.class) + @NotBlank(message = "终端节点不能为空", groups = ValidationGroup.Storage.S3.class) private String endpoint; /** @@ -94,8 +94,8 @@ public class StorageReq extends BaseReq { */ @Schema(description = "桶名称", example = "C:/continew-admin/data/file/") @Length(max = 255, message = "桶名称长度不能超过 {max} 个字符") - @NotBlank(message = "桶名称不能为空", groups = ValidateGroup.Storage.S3.class) - @NotBlank(message = "存储路径不能为空", groups = ValidateGroup.Storage.Local.class) + @NotBlank(message = "桶名称不能为空", groups = ValidationGroup.Storage.S3.class) + @NotBlank(message = "存储路径不能为空", groups = ValidationGroup.Storage.Local.class) private String bucketName; /** diff --git a/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserImportRowReq.java b/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserImportRowReq.java index 201942d4..b8fdf324 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserImportRowReq.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserImportRowReq.java @@ -25,7 +25,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import top.continew.admin.common.constant.RegexConstants; import top.continew.starter.extension.crud.model.req.BaseReq; -import top.continew.starter.extension.crud.util.ValidateGroup; +import top.continew.starter.extension.crud.validation.CrudValidationGroup; import java.io.Serial; @@ -59,7 +59,7 @@ public class UserImportRowReq extends BaseReq { /** * 密码 */ - @NotBlank(message = "密码不能为空", groups = ValidateGroup.Crud.Add.class) + @NotBlank(message = "密码不能为空", groups = CrudValidationGroup.Add.class) private String password; /** diff --git a/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserReq.java b/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserReq.java index 7cc23afc..9e001061 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserReq.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/model/req/user/UserReq.java @@ -28,7 +28,7 @@ import top.continew.admin.common.constant.RegexConstants; import top.continew.admin.common.enums.DisEnableStatusEnum; import top.continew.admin.common.enums.GenderEnum; import top.continew.starter.extension.crud.model.req.BaseReq; -import top.continew.starter.extension.crud.util.ValidateGroup; +import top.continew.starter.extension.crud.validation.CrudValidationGroup; import java.io.Serial; import java.util.List; @@ -66,7 +66,7 @@ public class UserReq extends BaseReq { * 密码(加密) */ @Schema(description = "密码(加密)", example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==") - @NotBlank(message = "密码不能为空", groups = ValidateGroup.Crud.Add.class) + @NotBlank(message = "密码不能为空", groups = CrudValidationGroup.Add.class) private String password; /** diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DeptServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DeptServiceImpl.java index 9cf36146..f1bd0bce 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DeptServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DeptServiceImpl.java @@ -34,7 +34,7 @@ import top.continew.admin.system.service.UserService; import top.continew.starter.core.validation.CheckUtils; import top.continew.starter.data.core.enums.DatabaseType; import top.continew.starter.data.core.util.MetaUtils; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import javax.sql.DataSource; import java.util.ArrayList; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictItemServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictItemServiceImpl.java index 9352c377..4aebb310 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictItemServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictItemServiceImpl.java @@ -35,7 +35,7 @@ import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.enums.BaseEnum; import top.continew.starter.core.validation.CheckUtils; import top.continew.starter.extension.crud.model.resp.LabelValueResp; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.util.*; import java.util.concurrent.ConcurrentHashMap; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictServiceImpl.java index 2e0dbdb0..070fd47d 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/DictServiceImpl.java @@ -27,7 +27,7 @@ import top.continew.admin.system.service.DictItemService; import top.continew.admin.system.service.DictService; import top.continew.starter.core.validation.CheckUtils; import top.continew.starter.extension.crud.model.resp.LabelValueResp; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.util.List; import java.util.Optional; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/FileServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/FileServiceImpl.java index 3d7c10d6..08548a4a 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/FileServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/FileServiceImpl.java @@ -44,7 +44,7 @@ import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.util.StrUtils; import top.continew.starter.core.util.URLUtils; import top.continew.starter.core.validation.CheckUtils; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.time.LocalDate; import java.util.List; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/MenuServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/MenuServiceImpl.java index 80669af3..511ab4af 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/MenuServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/MenuServiceImpl.java @@ -34,7 +34,7 @@ import top.continew.admin.system.service.MenuService; import top.continew.starter.cache.redisson.util.RedisUtils; import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.validation.CheckUtils; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.util.List; import java.util.Set; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java index 87ff8b27..b71df4b4 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/NoticeServiceImpl.java @@ -27,7 +27,7 @@ import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp; 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.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.util.List; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java index a94628c1..dad7e75f 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java @@ -42,7 +42,7 @@ import top.continew.admin.system.model.resp.RoleDetailResp; import top.continew.admin.system.model.resp.RoleResp; import top.continew.admin.system.service.*; import top.continew.starter.core.validation.CheckUtils; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import java.util.*; import java.util.stream.Collectors; diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/StorageServiceImpl.java b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/StorageServiceImpl.java index 8c3a6b8f..3aa01447 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/impl/StorageServiceImpl.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/impl/StorageServiceImpl.java @@ -37,13 +37,13 @@ import top.continew.admin.system.model.req.StorageReq; import top.continew.admin.system.model.resp.StorageResp; import top.continew.admin.system.service.FileService; import top.continew.admin.system.service.StorageService; -import top.continew.admin.system.util.ValidateGroup; +import top.continew.admin.system.validation.ValidationGroup; import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.util.ExceptionUtils; import top.continew.starter.core.util.URLUtils; import top.continew.starter.core.validation.CheckUtils; import top.continew.starter.core.validation.ValidationUtils; -import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import top.continew.starter.extension.crud.service.BaseServiceImpl; import top.continew.starter.web.util.SpringWebUtils; import java.util.Collections; @@ -129,7 +129,7 @@ public class StorageServiceImpl extends BaseServiceImpl { @Override - public BaseIdResp 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 diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java index 419b6550..2648e9b9 100644 --- a/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java +++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java @@ -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 { @Override - public BaseIdResp 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(); diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java index cb8d489a..4f747cdb 100644 --- a/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java +++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java @@ -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; diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java index 694f9d61..277167e0 100644 --- a/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java +++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java @@ -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; /** diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java index ac82fc39..435b72b3 100644 --- a/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java +++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java @@ -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 add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody UserReq req) { + public BaseIdResp add(@Validated(CrudValidationGroup.Add.class) @RequestBody UserReq req) { String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword())); ValidationUtils.throwIfNull(rawPassword, "密码解密失败"); ValidationUtils.throwIf(!ReUtil diff --git a/continew-webapi/src/main/resources/banner.txt b/continew-webapi/src/main/resources/banner.txt index 5377f289..dde2dc32 100644 --- a/continew-webapi/src/main/resources/banner.txt +++ b/continew-webapi/src/main/resources/banner.txt @@ -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} diff --git a/pom.xml b/pom.xml index f0ec997d..c640ba09 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ top.continew continew-starter - 2.7.4 + 2.7.5 top.continew