From 5d561bee3315a4bb1545ecf8f366e0596502e235 Mon Sep 17 00:00:00 2001 From: PIGCLOUD Date: Thu, 28 May 2026 15:56:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(pigx-codegen):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=94=9F=E6=88=90=E5=88=B0=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=20api=20=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 DataModelConstants 定义 API_PATH、ENTITY_PATH 等实体路径常量 - 实现 setEntityModel 方法,自动识别 `-biz` 模块同级 `-api` 模块,将实体生成路径和包名切换到 api 模块 - 更新 gen_template.sql 代码生成模板,使用 entityClassName、entityPath 等动态变量替代硬编码包路径 - 扩展 isSpringBoot3 判断逻辑,兼容 SpringBoot 4.x 主版本 --- .../pigx/codegen/service/impl/GeneratorServiceImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java index 358363eee..de1c74778 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java @@ -518,9 +518,8 @@ public class GeneratorServiceImpl implements GeneratorService { *

* 默认与业务模块同包,实体落到 {@code backendPath} 自身(即 biz 模块)。当 * {@code backendPath} 末尾形如 {@code xxx-biz} 且同级目录存在 {@code xxx-api} - * 模块时,自动切换为:实体写入 {@code xxx-api},包名调整为 - * {@code ..api.entity},便于在多个 biz 模块之间共享实体 - * 而不引入循环依赖。 + * 模块时,只将实体写入路径切换到 {@code xxx-api},Java 包名仍保持业务模块包名, + * 例如 {@code com.pig4cloud.pigx.aigc.entity}。 * * @param dataModel 数据模型,写入 entityPath、entityPackage、entityPackagePath、 * entityClassName、apiPath、hasApiModule @@ -537,7 +536,6 @@ public class GeneratorServiceImpl implements GeneratorService { if (resolvedApiPath.isPresent()) { apiPath = resolvedApiPath.get(); entityPath = apiPath; - entityPackage = StrUtil.format("{}.api.entity", modulePackage); hasApiModule = true; }