From f6a76efe1da4e6642696b70da98bb0237ce71992 Mon Sep 17 00:00:00 2001 From: xiayebo <364530740@qq.com> Date: Tue, 20 Jan 2026 09:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codegen/controller/CodeGenController.java | 4 ++++ .../funOperation/FunOperationSaveUpdateReq.java | 17 +++++++++++++++++ .../service/impl/FunOperationServiceImpl.java | 1 + 3 files changed, 22 insertions(+) diff --git a/src/main/java/com/cczsa/xinghe/codegen/controller/CodeGenController.java b/src/main/java/com/cczsa/xinghe/codegen/controller/CodeGenController.java index 6d95522..70315aa 100644 --- a/src/main/java/com/cczsa/xinghe/codegen/controller/CodeGenController.java +++ b/src/main/java/com/cczsa/xinghe/codegen/controller/CodeGenController.java @@ -2,6 +2,8 @@ package com.cczsa.xinghe.codegen.controller; import com.cczsa.xinghe.codegen.entity.domain.template.CodeGen; import com.cczsa.xinghe.codegen.service.CodeGenService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpHeaders; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController; * @date 2026/1/10 * @version 0.0.1 */ +@Tag(name = "代码生成") @RestController @RequestMapping("/codegen") @RequiredArgsConstructor @@ -24,6 +27,7 @@ public class CodeGenController { private final CodeGenService codeGenService; + @Operation(summary = "下载代码") @PostMapping("/download") public ResponseEntity downloadCode(@RequestBody @Valid CodeGen req) { try { diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java index 11f6776..e4e6d4b 100644 --- a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java @@ -6,6 +6,7 @@ import com.cczsa.xinghe.codegen.entity.enums.UsableConfigEnum; import com.cczsa.xinghe.codegen.handler.PostgreSQLJsonTypeHandler; import com.mybatisflex.annotation.Column; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.AssertTrue; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; @@ -103,4 +104,20 @@ public class FunOperationSaveUpdateReq implements Serializable { @Schema(description = "路径参数") private String pathParams; + @AssertTrue(message = "当不需要响应参数时,也不能分页") + public boolean isValidPageAndResParams() { + if (Boolean.FALSE.equals(isResParams)) { + return Boolean.FALSE.equals(isPage); + } + return true; + } + + @AssertTrue(message = "当需要请求参数时,路径参数必须为空") + public boolean isValidReqParamsAndPathParams() { + if (Boolean.TRUE.equals(isReqParams)) { + return pathParams == null || pathParams.isEmpty(); + } + return true; + } + } diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java index d0d5ff8..2597860 100644 --- a/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java +++ b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java @@ -60,6 +60,7 @@ public class FunOperationServiceImpl implements FunOperationService { .like(FunOperationEntity::getFunName, req.getFunName(), StrUtil.isNotBlank(req.getFunName())) .eq(FunItemEntity::getIsTenant, isTenant, isTenantNotNull) .eq(FunOperationEntity::getIsGreenLight,false,isTenantNotNull) // 直接放行,不用提供绑定 + .orderBy(FunOperationEntity::getId, true) .orderBy(FunOperationEntity::getSortOrder, false); List funOperationQueryRes = funOperationMapper.selectListByQueryAs(queryWrapper, FunOperationQueryRes.class); return XResult.ok(funOperationQueryRes);