From f3b3a454fce1f796229cfbc3963c7284ac48159e Mon Sep 17 00:00:00 2001 From: xiayebo <364530740@qq.com> Date: Fri, 9 Jan 2026 15:52:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 38 +++++ pom.xml | 131 ++++++++++++++++++ .../xinghe/codegen/CodegenApplication.java | 13 ++ .../codegen/controller/FunItemController.java | 55 ++++++++ .../controller/FunModuleController.java | 53 +++++++ .../controller/FunOperationController.java | 52 +++++++ .../xinghe/codegen/entity/BaseEntity.java | 10 ++ .../xinghe/codegen/entity/FunItemEntity.java | 69 +++++++++ .../codegen/entity/FunModuleEntity.java | 69 +++++++++ .../codegen/entity/FunOperationEntity.java | 100 +++++++++++++ .../codegen/entity/enums/FunTypeEnum.java | 63 +++++++++ .../codegen/entity/enums/RequestTypeEnum.java | 43 ++++++ .../entity/req/funItem/FunItemQueryReq.java | 22 +++ .../req/funItem/FunItemSaveUpdateReq.java | 22 +++ .../req/funModule/FunModuleQueryReq.java | 22 +++ .../req/funModule/FunModuleSaveUpdateReq.java | 22 +++ .../funOperation/FunOperationQueryReq.java | 22 +++ .../FunOperationSaveUpdateReq.java | 22 +++ .../entity/res/funItem/FunItemQueryRes.java | 22 +++ .../res/funModule/FunModuleQueryRes.java | 22 +++ .../funOperation/FunOperationQueryRes.java | 22 +++ .../handler/PostgreSQLJsonTypeHandler.java | 64 +++++++++ .../xinghe/codegen/mapper/FunItemMapper.java | 16 +++ .../codegen/mapper/FunModuleMapper.java | 16 +++ .../codegen/mapper/FunOperationMapper.java | 16 +++ .../xinghe/codegen/mapper/def/FunItemDef.java | 82 +++++++++++ .../codegen/mapper/def/FunModuleDef.java | 82 +++++++++++ .../codegen/mapper/def/FunOperationDef.java | 107 ++++++++++++++ .../codegen/service/FunItemService.java | 32 +++++ .../codegen/service/FunModuleService.java | 32 +++++ .../codegen/service/FunOperationService.java | 32 +++++ .../service/impl/FunItemServiceImpl.java | 49 +++++++ .../service/impl/FunModuleServiceImpl.java | 49 +++++++ .../service/impl/FunOperationServiceImpl.java | 49 +++++++ .../cczsa/xinghe/codegen/util/XResult.java | 66 +++++++++ .../xinghe/codegen/util/XResultCode.java | 24 ++++ src/main/resources/application.yml | 18 +++ 37 files changed, 1628 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/cczsa/xinghe/codegen/CodegenApplication.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/controller/FunItemController.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/controller/FunModuleController.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/controller/FunOperationController.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/BaseEntity.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/FunItemEntity.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/FunModuleEntity.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/FunOperationEntity.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/enums/FunTypeEnum.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/enums/RequestTypeEnum.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemQueryReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemSaveUpdateReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleQueryReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleSaveUpdateReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationQueryReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/res/funItem/FunItemQueryRes.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/res/funModule/FunModuleQueryRes.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/entity/res/funOperation/FunOperationQueryRes.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/handler/PostgreSQLJsonTypeHandler.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/FunItemMapper.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/FunModuleMapper.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/FunOperationMapper.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunItemDef.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunModuleDef.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunOperationDef.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/FunItemService.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/FunModuleService.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/FunOperationService.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/impl/FunItemServiceImpl.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/impl/FunModuleServiceImpl.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/util/XResult.java create mode 100644 src/main/java/com/cczsa/xinghe/codegen/util/XResultCode.java create mode 100644 src/main/resources/application.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4f49aba --- /dev/null +++ b/pom.xml @@ -0,0 +1,131 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.5.9 + + + com.cczsa.xinghe.codegen + xinghe-codegen + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + 1.11.5 + 2.2.19 + 4.4.0 + 2.0.57 + + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + com.mybatis-flex + mybatis-flex-spring-boot3-starter + ${mybatis-flex.version} + + + + + + + + + + org.hibernate.orm + hibernate-hikaricp + + + org.postgresql + postgresql + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + io.swagger.core.v3 + swagger-annotations-jakarta + ${swagger.annotations.version} + + + + com.alibaba.fastjson2 + fastjson2 + ${fastjson2.version} + + + org.postgresql + postgresql + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + ${knife4j-gateway-spring-boot-starter.version} + + + io.swagger.core.v3 + swagger-annotations-jakarta + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.projectlombok + lombok + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/CodegenApplication.java b/src/main/java/com/cczsa/xinghe/codegen/CodegenApplication.java new file mode 100644 index 0000000..52f0334 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/CodegenApplication.java @@ -0,0 +1,13 @@ +package com.cczsa.xinghe.codegen; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CodegenApplication { + + public static void main(String[] args) { + SpringApplication.run(CodegenApplication.class, args); + } + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/controller/FunItemController.java b/src/main/java/com/cczsa/xinghe/codegen/controller/FunItemController.java new file mode 100644 index 0000000..eb8a06c --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/controller/FunItemController.java @@ -0,0 +1,55 @@ +package com.cczsa.xinghe.codegen.controller; + + +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funItem.FunItemQueryRes; +import com.cczsa.xinghe.codegen.service.FunItemService; +import com.cczsa.xinghe.codegen.util.XResult; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 功能管理 控制层。 + * + * @author xia + * @version 0.0.1 + */ +@Tag(name = "功能管理") +@RequiredArgsConstructor +@RestController +@RequestMapping("/funItem") +public class FunItemController { + + private final FunItemService funitemService; + + + @PostMapping("/query") + public XResult query(@RequestBody @Valid FunItemQueryReq req ) { + return funitemService.query(req); + } + + + @Operation(summary = "创建/修改功能", description = "创建/修改功能") + @PostMapping("/save/update") + public XResult saveUpdate(@RequestBody @Valid FunItemSaveUpdateReq req ) { + return funitemService.saveUpdate(req); + } + + + @Operation(summary = "删除功能", description = "删除功能") + @DeleteMapping("/delete") + public XResult delete() { + return funitemService.delete(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/controller/FunModuleController.java b/src/main/java/com/cczsa/xinghe/codegen/controller/FunModuleController.java new file mode 100644 index 0000000..fcf16f2 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/controller/FunModuleController.java @@ -0,0 +1,53 @@ +package com.cczsa.xinghe.codegen.controller; + + +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funModule.FunModuleQueryRes; +import com.cczsa.xinghe.codegen.service.FunModuleService; +import com.cczsa.xinghe.codegen.util.XResult; +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.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 模块管理 控制层。 + * + * @author xia + * @version 0.0.1 + */ +@Tag(name = "模块管理") +@RequiredArgsConstructor +@RestController +@RequestMapping("/funModule") +public class FunModuleController { + + private final FunModuleService funmoduleService; + + @Operation(summary = "获取模块列表", description = "获取模块列表") + @PostMapping("/query") + public XResult query(@RequestBody @Valid FunModuleQueryReq req ) { + return funmoduleService.query(req); + } + + @Operation(summary = "创建/修改模块", description = "创建/修改模块") + @PostMapping("/save/update") + public XResult saveUpdate(@RequestBody @Valid FunModuleSaveUpdateReq req ) { + return funmoduleService.saveUpdate(req); + } + + @Operation(summary = "删除模块", description = "删除模块") + @DeleteMapping("/delete") + public XResult delete() { + return funmoduleService.delete(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/controller/FunOperationController.java b/src/main/java/com/cczsa/xinghe/codegen/controller/FunOperationController.java new file mode 100644 index 0000000..6b057e5 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/controller/FunOperationController.java @@ -0,0 +1,52 @@ +package com.cczsa.xinghe.codegen.controller; + +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funOperation.FunOperationQueryRes; +import com.cczsa.xinghe.codegen.service.FunOperationService; +import com.cczsa.xinghe.codegen.util.XResult; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 操作管理 控制层。 + * + * @author xia + * @version 0.0.1 + */ +@Tag(name = "操作管理") +@RequiredArgsConstructor +@RestController +@RequestMapping("/funOperation") +public class FunOperationController { + + private final FunOperationService funoperationService; + + @Operation(summary = "获取操作列表", description = "获取操作列表") + @PostMapping("/query") + public XResult query(@RequestBody @Valid FunOperationQueryReq req ) { + return funoperationService.query(req); + } + + @Operation(summary = "创建/修改操作", description = "创建/修改操作") + @PostMapping("/save/update") + public XResult saveUpdate(@RequestBody @Valid FunOperationSaveUpdateReq req ) { + return funoperationService.saveUpdate(req); + } + + @Operation(summary = "删除操作", description = "删除操作") + @DeleteMapping("/delete") + public XResult delete() { + return funoperationService.delete(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/BaseEntity.java b/src/main/java/com/cczsa/xinghe/codegen/entity/BaseEntity.java new file mode 100644 index 0000000..3a9ffa8 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/BaseEntity.java @@ -0,0 +1,10 @@ +package com.cczsa.xinghe.codegen.entity; + +/** + * 基类监听器 + * @author xia + * @date 2025/9/17 + * @version 0.0.1 + */ +public class BaseEntity { +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/FunItemEntity.java b/src/main/java/com/cczsa/xinghe/codegen/entity/FunItemEntity.java new file mode 100644 index 0000000..03b37c7 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/FunItemEntity.java @@ -0,0 +1,69 @@ +package com.cczsa.xinghe.codegen.entity; + +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; +import java.io.Serializable; + +import java.io.Serial; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; + +/** + * 功能 实体类。 + * + * @author My + * @since 0.0.1 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Table("cg_fun_item") +public class FunItemEntity extends BaseEntity implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * id + */ + @Id(keyType = KeyType.None) + private Long id; + + /** + * 模块ID + */ + private Long moduleId; + + /** + * 功能名称 + */ + private String itemName; + + /** + * 功能编码 + */ + private String itemCode; + + /** + * 是否租户 + */ + private Boolean isTenant; + + /** + * 说明 + */ + private String describe; + + /** + * 排序 + */ + private Integer sortOrder; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/FunModuleEntity.java b/src/main/java/com/cczsa/xinghe/codegen/entity/FunModuleEntity.java new file mode 100644 index 0000000..4f4c4b1 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/FunModuleEntity.java @@ -0,0 +1,69 @@ +package com.cczsa.xinghe.codegen.entity; + +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; +import java.io.Serializable; + +import java.io.Serial; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; + +/** + * 模块 实体类。 + * + * @author My + * @since 0.0.1 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Table("cg_fun_module") +public class FunModuleEntity extends BaseEntity implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * id + */ + @Id(keyType = KeyType.None) + private Long id; + + /** + * 模块名称 + */ + private String moduleName; + + /** + * 模块编码 + */ + private String moduleCode; + + /** + * 描述 + */ + private String describe; + + /** + * 包名称 + */ + private String packageName; + + /** + * 参数包名 + */ + private String apiPackageName; + + /** + * 排序 + */ + private Integer sortOrder; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/FunOperationEntity.java b/src/main/java/com/cczsa/xinghe/codegen/entity/FunOperationEntity.java new file mode 100644 index 0000000..a7f5bcc --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/FunOperationEntity.java @@ -0,0 +1,100 @@ +package com.cczsa.xinghe.codegen.entity; + +import com.cczsa.xinghe.codegen.entity.enums.FunTypeEnum; +import com.cczsa.xinghe.codegen.entity.enums.RequestTypeEnum; +import com.cczsa.xinghe.codegen.handler.PostgreSQLJsonTypeHandler; +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * 操作 实体类。 + * + * @author My + * @since 0.0.1 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Table("cg_fun_operation") +public class FunOperationEntity extends BaseEntity implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * id + */ + @Id(keyType = KeyType.None) + private Long id; + + /** + * 模块ID + */ + private Long moduleId; + + /** + * 功能ID + */ + private Long itemId; + + /** + * 直接放行 + */ + private Boolean isGreenLight; + + /** + * 操作名称 + */ + private String funName; + + /** + * 操作编码 + */ + private String operationCode; + + /** + * 操作类型>>查>>改>>删>>增 + */ + private FunTypeEnum funType; + + /** + * 请求类型 + */ + private RequestTypeEnum requestType; + + /** + * 可配置数据类型json[] + */ + @Column(typeHandler = PostgreSQLJsonTypeHandler.class) + private List usableConfig; + + /** + * 可配置字段 + */ + @Column(typeHandler = PostgreSQLJsonTypeHandler.class) + private List fieldCofnig; + + /** + * 排序 + */ + private Integer sortOrder; + + /** + * 说明 + */ + private String describe; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/enums/FunTypeEnum.java b/src/main/java/com/cczsa/xinghe/codegen/entity/enums/FunTypeEnum.java new file mode 100644 index 0000000..1942b14 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/enums/FunTypeEnum.java @@ -0,0 +1,63 @@ +package com.cczsa.xinghe.codegen.entity.enums; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.mybatisflex.annotation.EnumValue; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; + +/** + * 操作类型枚举 + * @author My + */ +@Schema(description = "绑定操作类型", + example = "0", + allowableValues = {"0: 新增", "1: 删除", "2: 修改", "3: 查询", + "4: 上传", "5: 下载", "6: 导入", "7: 导出", "8: 打印", + "9: 注册", "10: 登录", "11: 登出", + "12: 短信", "13: 邮件", "14: 微信", + "99: 其它" + }) +@Getter +public enum FunTypeEnum { + // 基本数据操作 + ADD(0,"新增"), + DELETE(1,"删除"), + EDIT(2,"修改"), + QUERY(3,"查询"), + + // 文件相关操作 + UPLOAD(4,"上传"), + DOWNLOAD(5,"下载"), + IMPORT(6,"导入"), + EXPORT(7,"导出"), + PRINT(8,"打印"), + + // 用户认证相关 + REGISTER(9,"注册"), + LOGIN(10,"登录"), + LOGOUT(11,"登出"), + + // 通知和通信 + SMS(12,"短信"), + EMAIL(13,"邮件"), + WECHAT(14,"微信"), + + + // 其它 + OTHER(99,"其它") + ; + + private final int code; + private final String desc; + + FunTypeEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } + + @JsonValue + @EnumValue + public int getCode() { + return code; + } +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/enums/RequestTypeEnum.java b/src/main/java/com/cczsa/xinghe/codegen/entity/enums/RequestTypeEnum.java new file mode 100644 index 0000000..0527f01 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/enums/RequestTypeEnum.java @@ -0,0 +1,43 @@ +package com.cczsa.xinghe.codegen.entity.enums; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.mybatisflex.annotation.EnumValue; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; + +/** + * 请求类型枚举 + * + * @author My + */ +@Schema(description = "HTTP请求类型", + example = "0", + allowableValues = {"0: GET", "1: HEAD", "2: POST", "3: PUT", + "4: PATCH", "5: DELETE", "6: OPTIONS", "7: TRACE" + }) +@Getter +public enum RequestTypeEnum { + + GET(0, "GET"), + HEAD(1, "HEAD"), + POST(2, "POST"), + PUT(3, "PUT"), + PATCH(4, "PATCH"), + DELETE(5, "DELETE"), + OPTIONS(6, "OPTIONS"), + TRACE(7, "TRACE"); + + private final int code; + private final String desc; + + RequestTypeEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } + + @JsonValue + @EnumValue + public int getCode() { + return code; + } +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemQueryReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemQueryReq.java new file mode 100644 index 0000000..fc415ea --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemQueryReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funItem; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取功能列表 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取功能列表-参数") +public class FunItemQueryReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemSaveUpdateReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemSaveUpdateReq.java new file mode 100644 index 0000000..39b2ee3 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funItem/FunItemSaveUpdateReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funItem; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 创建/修改功能 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "创建/修改功能-参数") +public class FunItemSaveUpdateReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleQueryReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleQueryReq.java new file mode 100644 index 0000000..063add4 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleQueryReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funModule; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取模块列表 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取模块列表-参数") +public class FunModuleQueryReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleSaveUpdateReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleSaveUpdateReq.java new file mode 100644 index 0000000..8b4d5ff --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funModule/FunModuleSaveUpdateReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funModule; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 创建/修改模块 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "创建/修改模块-参数") +public class FunModuleSaveUpdateReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationQueryReq.java b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationQueryReq.java new file mode 100644 index 0000000..67a4856 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationQueryReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funOperation; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取操作列表 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取操作列表-参数") +public class FunOperationQueryReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} 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 new file mode 100644 index 0000000..15137ad --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/req/funOperation/FunOperationSaveUpdateReq.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.req.funOperation; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 创建/修改操作 请求参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "创建/修改操作-参数") +public class FunOperationSaveUpdateReq implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/res/funItem/FunItemQueryRes.java b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funItem/FunItemQueryRes.java new file mode 100644 index 0000000..5da4356 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funItem/FunItemQueryRes.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.res.funItem; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取功能列表 响应参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取功能列表-响应") +public class FunItemQueryRes implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/res/funModule/FunModuleQueryRes.java b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funModule/FunModuleQueryRes.java new file mode 100644 index 0000000..0e16b16 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funModule/FunModuleQueryRes.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.res.funModule; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取模块列表 响应参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取模块列表-响应") +public class FunModuleQueryRes implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/entity/res/funOperation/FunOperationQueryRes.java b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funOperation/FunOperationQueryRes.java new file mode 100644 index 0000000..4a36975 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/entity/res/funOperation/FunOperationQueryRes.java @@ -0,0 +1,22 @@ +package com.cczsa.xinghe.codegen.entity.res.funOperation; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import java.io.Serial; +import java.io.Serializable; + +/** + * 获取操作列表 响应参数 + * @author xia + * @version 0.0.1 + */ +@Getter +@Setter +@Schema(description = "获取操作列表-响应") +public class FunOperationQueryRes implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/handler/PostgreSQLJsonTypeHandler.java b/src/main/java/com/cczsa/xinghe/codegen/handler/PostgreSQLJsonTypeHandler.java new file mode 100644 index 0000000..b6d0128 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/handler/PostgreSQLJsonTypeHandler.java @@ -0,0 +1,64 @@ +package com.cczsa.xinghe.codegen.handler; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.util.ParameterizedTypeImpl; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.postgresql.util.PGobject; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * @author xia + * @date 2025/9/20 + * @version 0.0.1 + */ +public class PostgreSQLJsonTypeHandler extends BaseTypeHandler { + private final Class type; + private Class genericType; + + public PostgreSQLJsonTypeHandler(Class type) { + this.type = type; + } + + public PostgreSQLJsonTypeHandler(Class type, Class genericType) { + this.type = type; + this.genericType = genericType; + } + + private T parseJson(String json) { + if (genericType != null) { + return JSON.parseObject(json, new ParameterizedTypeImpl(type,genericType)); + } + return JSON.parseObject(json, type); + } + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException { + PGobject pgObject = new PGobject(); + pgObject.setType("json"); // 或 "jsonb",根据你的数据库字段类型调整 + pgObject.setValue(JSON.toJSONString(parameter)); + ps.setObject(i, pgObject); + } + + @Override + public T getNullableResult(ResultSet rs, String columnName) throws SQLException { + String json = rs.getString(columnName); + return parseJson(json); + } + + @Override + public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String json = rs.getString(columnIndex); + return parseJson(json); + } + + @Override + public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + String json = cs.getString(columnIndex); + return parseJson(json); + } +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/FunItemMapper.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunItemMapper.java new file mode 100644 index 0000000..9ba5452 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunItemMapper.java @@ -0,0 +1,16 @@ +package com.cczsa.xinghe.codegen.mapper; + +import org.apache.ibatis.annotations.Mapper; +import com.mybatisflex.core.BaseMapper; +import com.cczsa.xinghe.codegen.entity.FunItemEntity; + +/** + * 功能 映射层。 + * + * @author My + * @since 0.0.1 + */ +@Mapper +public interface FunItemMapper extends BaseMapper { + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/FunModuleMapper.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunModuleMapper.java new file mode 100644 index 0000000..d7a6c93 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunModuleMapper.java @@ -0,0 +1,16 @@ +package com.cczsa.xinghe.codegen.mapper; + +import org.apache.ibatis.annotations.Mapper; +import com.mybatisflex.core.BaseMapper; +import com.cczsa.xinghe.codegen.entity.FunModuleEntity; + +/** + * 模块 映射层。 + * + * @author My + * @since 0.0.1 + */ +@Mapper +public interface FunModuleMapper extends BaseMapper { + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/FunOperationMapper.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunOperationMapper.java new file mode 100644 index 0000000..13c3ecf --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/FunOperationMapper.java @@ -0,0 +1,16 @@ +package com.cczsa.xinghe.codegen.mapper; + +import org.apache.ibatis.annotations.Mapper; +import com.mybatisflex.core.BaseMapper; +import com.cczsa.xinghe.codegen.entity.FunOperationEntity; + +/** + * 操作 映射层。 + * + * @author My + * @since 0.0.1 + */ +@Mapper +public interface FunOperationMapper extends BaseMapper { + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunItemDef.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunItemDef.java new file mode 100644 index 0000000..5075b61 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunItemDef.java @@ -0,0 +1,82 @@ +package com.cczsa.xinghe.codegen.mapper.def; + +import com.mybatisflex.core.query.QueryColumn; +import com.mybatisflex.core.table.TableDef; + +import java.io.Serial; + +/** + * 功能 表定义层。 + * + * @author My + * @since 0.0.1 + */ +public class FunItemDef extends TableDef { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 功能 + */ + public static final FunItemDef FUN_ITEM_ENTITY = new FunItemDef(); + + /** + * id + */ + public final QueryColumn ID = new QueryColumn(this, "id"); + + /** + * 说明 + */ + public final QueryColumn DESCRIBE = new QueryColumn(this, "describe"); + + /** + * 是否租户 + */ + public final QueryColumn IS_TENANT = new QueryColumn(this, "is_tenant"); + + /** + * 功能编码 + */ + public final QueryColumn ITEM_CODE = new QueryColumn(this, "item_code"); + + /** + * 功能名称 + */ + public final QueryColumn ITEM_NAME = new QueryColumn(this, "item_name"); + + /** + * 模块ID + */ + public final QueryColumn MODULE_ID = new QueryColumn(this, "module_id"); + + /** + * 排序 + */ + public final QueryColumn SORT_ORDER = new QueryColumn(this, "sort_order"); + + /** + * 所有字段。 + */ + public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*"); + + /** + * 默认字段,不包含逻辑删除或者 large 等字段。 + */ + public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, MODULE_ID, ITEM_NAME, ITEM_CODE, IS_TENANT, DESCRIBE, SORT_ORDER}; + + public FunItemDef() { + super("", "cg_fun_item"); + } + + private FunItemDef(String schema, String name, String alisa) { + super(schema, name, alisa); + } + + public FunItemDef as(String alias) { + String key = getNameWithSchema() + "." + alias; + return getCache(key, k -> new FunItemDef("", "cg_fun_item", alias)); + } + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunModuleDef.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunModuleDef.java new file mode 100644 index 0000000..b18f20c --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunModuleDef.java @@ -0,0 +1,82 @@ +package com.cczsa.xinghe.codegen.mapper.def; + +import com.mybatisflex.core.query.QueryColumn; +import com.mybatisflex.core.table.TableDef; + +import java.io.Serial; + +/** + * 模块 表定义层。 + * + * @author My + * @since 0.0.1 + */ +public class FunModuleDef extends TableDef { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 模块 + */ + public static final FunModuleDef FUN_MODULE_ENTITY = new FunModuleDef(); + + /** + * id + */ + public final QueryColumn ID = new QueryColumn(this, "id"); + + /** + * 描述 + */ + public final QueryColumn DESCRIBE = new QueryColumn(this, "describe"); + + /** + * 排序 + */ + public final QueryColumn SORT_ORDER = new QueryColumn(this, "sort_order"); + + /** + * 模块编码 + */ + public final QueryColumn MODULE_CODE = new QueryColumn(this, "module_code"); + + /** + * 模块名称 + */ + public final QueryColumn MODULE_NAME = new QueryColumn(this, "module_name"); + + /** + * 包名称 + */ + public final QueryColumn PACKAGE_NAME = new QueryColumn(this, "package_name"); + + /** + * 参数包名 + */ + public final QueryColumn API_PACKAGE_NAME = new QueryColumn(this, "api_package_name"); + + /** + * 所有字段。 + */ + public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*"); + + /** + * 默认字段,不包含逻辑删除或者 large 等字段。 + */ + public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, MODULE_NAME, MODULE_CODE, DESCRIBE, PACKAGE_NAME, API_PACKAGE_NAME, SORT_ORDER}; + + public FunModuleDef() { + super("", "cg_fun_module"); + } + + private FunModuleDef(String schema, String name, String alisa) { + super(schema, name, alisa); + } + + public FunModuleDef as(String alias) { + String key = getNameWithSchema() + "." + alias; + return getCache(key, k -> new FunModuleDef("", "cg_fun_module", alias)); + } + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunOperationDef.java b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunOperationDef.java new file mode 100644 index 0000000..3945c3a --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/mapper/def/FunOperationDef.java @@ -0,0 +1,107 @@ +package com.cczsa.xinghe.codegen.mapper.def; + +import com.mybatisflex.core.query.QueryColumn; +import com.mybatisflex.core.table.TableDef; + +import java.io.Serial; + +/** + * 操作 表定义层。 + * + * @author My + * @since 0.0.1 + */ +public class FunOperationDef extends TableDef { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 操作 + */ + public static final FunOperationDef FUN_OPERATION_ENTITY = new FunOperationDef(); + + /** + * id + */ + public final QueryColumn ID = new QueryColumn(this, "id"); + + /** + * 功能ID + */ + public final QueryColumn ITEM_ID = new QueryColumn(this, "item_id"); + + /** + * 操作名称 + */ + public final QueryColumn FUN_NAME = new QueryColumn(this, "fun_name"); + + /** + * 操作类型>>查>>改>>删>>增 + */ + public final QueryColumn FUN_TYPE = new QueryColumn(this, "fun_type"); + + /** + * 说明 + */ + public final QueryColumn DESCRIBE = new QueryColumn(this, "describe"); + + /** + * 模块ID + */ + public final QueryColumn MODULE_ID = new QueryColumn(this, "module_id"); + + /** + * 排序 + */ + public final QueryColumn SORT_ORDER = new QueryColumn(this, "sort_order"); + + /** + * 可配置字段 + */ + public final QueryColumn FIELD_COFNIG = new QueryColumn(this, "field_cofnig"); + + /** + * 请求类型 + */ + public final QueryColumn REQUEST_TYPE = new QueryColumn(this, "request_type"); + + /** + * 直接放行 + */ + public final QueryColumn IS_GREEN_LIGHT = new QueryColumn(this, "is_green_light"); + + /** + * 可配置数据类型json[] + */ + public final QueryColumn USABLE_CONFIG = new QueryColumn(this, "usable_config"); + + /** + * 操作编码 + */ + public final QueryColumn OPERATION_CODE = new QueryColumn(this, "operation_code"); + + /** + * 所有字段。 + */ + public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*"); + + /** + * 默认字段,不包含逻辑删除或者 large 等字段。 + */ + public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, MODULE_ID, ITEM_ID, IS_GREEN_LIGHT, FUN_NAME, OPERATION_CODE, FUN_TYPE, REQUEST_TYPE, USABLE_CONFIG, FIELD_COFNIG, SORT_ORDER, DESCRIBE}; + + public FunOperationDef() { + super("", "cg_fun_operation"); + } + + private FunOperationDef(String schema, String name, String alisa) { + super(schema, name, alisa); + } + + public FunOperationDef as(String alias) { + String key = getNameWithSchema() + "." + alias; + return getCache(key, k -> new FunOperationDef("", "cg_fun_operation", alias)); + } + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/FunItemService.java b/src/main/java/com/cczsa/xinghe/codegen/service/FunItemService.java new file mode 100644 index 0000000..1d1e6c3 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/FunItemService.java @@ -0,0 +1,32 @@ +package com.cczsa.xinghe.codegen.service; + +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funItem.FunItemQueryRes; +import com.cczsa.xinghe.codegen.util.XResult; + +/** + * 功能管理 服务层接口。 + * + * @author xia + * @version 0.0.1 + */ +public interface FunItemService { + + /** + * 获取功能列表 + */ + XResult query(FunItemQueryReq req); + + /** + * 创建/修改功能 + */ + XResult saveUpdate(FunItemSaveUpdateReq req); + + /** + * 删除功能 + */ + XResult delete(); + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/FunModuleService.java b/src/main/java/com/cczsa/xinghe/codegen/service/FunModuleService.java new file mode 100644 index 0000000..369d438 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/FunModuleService.java @@ -0,0 +1,32 @@ +package com.cczsa.xinghe.codegen.service; + +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funModule.FunModuleQueryRes; +import com.cczsa.xinghe.codegen.util.XResult; + +/** + * 模块管理 服务层接口。 + * + * @author xia + * @version 0.0.1 + */ +public interface FunModuleService { + + /** + * 获取模块列表 + */ + XResult query(FunModuleQueryReq req); + + /** + * 创建/修改模块 + */ + XResult saveUpdate(FunModuleSaveUpdateReq req); + + /** + * 删除模块 + */ + XResult delete(); + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/FunOperationService.java b/src/main/java/com/cczsa/xinghe/codegen/service/FunOperationService.java new file mode 100644 index 0000000..cc8655c --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/FunOperationService.java @@ -0,0 +1,32 @@ +package com.cczsa.xinghe.codegen.service; + +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funOperation.FunOperationQueryRes; +import com.cczsa.xinghe.codegen.util.XResult; + +/** + * 操作管理 服务层接口。 + * + * @author xia + * @version 0.0.1 + */ +public interface FunOperationService { + + /** + * 获取操作列表 + */ + XResult query(FunOperationQueryReq req); + + /** + * 创建/修改操作 + */ + XResult saveUpdate(FunOperationSaveUpdateReq req); + + /** + * 删除操作 + */ + XResult delete(); + + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunItemServiceImpl.java b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunItemServiceImpl.java new file mode 100644 index 0000000..4d6e7ca --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunItemServiceImpl.java @@ -0,0 +1,49 @@ +package com.cczsa.xinghe.codegen.service.impl; + +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funItem.FunItemSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funItem.FunItemQueryRes; +import com.cczsa.xinghe.codegen.service.FunItemService; +import com.cczsa.xinghe.codegen.util.XResult; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** +* 功能管理 服务层实现。 +* +* @author xia +* @version 0.0.1 +*/ +@Service +@RequiredArgsConstructor +public class FunItemServiceImpl implements FunItemService { + + + /** + * 获取功能列表 + */ + @Override + public XResult query(FunItemQueryReq req) { + // TODO 实现 获取功能列表 业务逻辑 + return null; + } + + /** + * 创建/修改功能 + */ + @Override + public XResult saveUpdate(FunItemSaveUpdateReq req) { + // TODO 实现 创建/修改功能 业务逻辑 + return null; + } + + /** + * 删除功能 + */ + @Override + public XResult delete() { + // TODO 实现 删除功能 业务逻辑 + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunModuleServiceImpl.java b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunModuleServiceImpl.java new file mode 100644 index 0000000..c401733 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunModuleServiceImpl.java @@ -0,0 +1,49 @@ +package com.cczsa.xinghe.codegen.service.impl; + +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funModule.FunModuleSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funModule.FunModuleQueryRes; +import com.cczsa.xinghe.codegen.service.FunModuleService; +import com.cczsa.xinghe.codegen.util.XResult; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** +* 模块管理 服务层实现。 +* +* @author xia +* @version 0.0.1 +*/ +@Service +@RequiredArgsConstructor +public class FunModuleServiceImpl implements FunModuleService { + + + /** + * 获取模块列表 + */ + @Override + public XResult query(FunModuleQueryReq req) { + // TODO 实现 获取模块列表 业务逻辑 + return null; + } + + /** + * 创建/修改模块 + */ + @Override + public XResult saveUpdate(FunModuleSaveUpdateReq req) { + // TODO 实现 创建/修改模块 业务逻辑 + return null; + } + + /** + * 删除模块 + */ + @Override + public XResult delete() { + // TODO 实现 删除模块 业务逻辑 + return null; + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000..fd5a816 --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/service/impl/FunOperationServiceImpl.java @@ -0,0 +1,49 @@ +package com.cczsa.xinghe.codegen.service.impl; + +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationQueryReq; +import com.cczsa.xinghe.codegen.entity.req.funOperation.FunOperationSaveUpdateReq; +import com.cczsa.xinghe.codegen.entity.res.funOperation.FunOperationQueryRes; +import com.cczsa.xinghe.codegen.service.FunOperationService; +import com.cczsa.xinghe.codegen.util.XResult; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** +* 操作管理 服务层实现。 +* +* @author xia +* @version 0.0.1 +*/ +@Service +@RequiredArgsConstructor +public class FunOperationServiceImpl implements FunOperationService { + + + /** + * 获取操作列表 + */ + @Override + public XResult query(FunOperationQueryReq req) { + // TODO 实现 获取操作列表 业务逻辑 + return null; + } + + /** + * 创建/修改操作 + */ + @Override + public XResult saveUpdate(FunOperationSaveUpdateReq req) { + // TODO 实现 创建/修改操作 业务逻辑 + return null; + } + + /** + * 删除操作 + */ + @Override + public XResult delete() { + // TODO 实现 删除操作 业务逻辑 + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/com/cczsa/xinghe/codegen/util/XResult.java b/src/main/java/com/cczsa/xinghe/codegen/util/XResult.java new file mode 100644 index 0000000..b7fe76b --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/util/XResult.java @@ -0,0 +1,66 @@ +package com.cczsa.xinghe.codegen.util; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author xia + * @date 2025/9/9 + * @version 0.0.1 + */ +@Data +@Schema(description = "响应") +public class XResult implements Serializable { + + @Schema(description = "返回标记:成功标记200,其它标记失败") + private int code; + @Schema(description = "返回信息") + private String msg; + @Schema(description = "数据") + private T data; + + public XResult(int code, String msg, T data) { + this.code = code; + this.msg = msg; + this.data = data; + } + + public static XResult ok() { + return new XResult<>(XResultCode.SUCCEED.getCode(), XResultCode.SUCCEED.getMessage(),null); + } + public static XResult ok(T data) { + return new XResult<>(XResultCode.SUCCEED.getCode(), XResultCode.SUCCEED.getMessage(), data); + } + + public static XResult ok(T data, String msg) { + return new XResult<>(XResultCode.SUCCEED.getCode(), msg, data); + } + + + public static XResult failed() { + return new XResult<>(XResultCode.FAILED.getCode(), XResultCode.FAILED.getMessage(), null); + } + + public static XResult failed(XResultCode resultCode) { + return new XResult<>(resultCode.getCode(), resultCode.getMessage(), null); + } + public static XResult failed(XResultCode resultCode, String msg) { + return new XResult<>(resultCode.getCode(), msg, null); + } + public static XResult failed(String msg) { + return new XResult<>(XResultCode.FAILED.getCode(), msg, null); + } + + public static XResult failed(T data) { + return new XResult<>(XResultCode.FAILED.getCode(), XResultCode.FAILED.getMessage(), data); + } + + // 链式调用支持 + public XResult setData(T data) { + this.data = data; + return this; + } + +} diff --git a/src/main/java/com/cczsa/xinghe/codegen/util/XResultCode.java b/src/main/java/com/cczsa/xinghe/codegen/util/XResultCode.java new file mode 100644 index 0000000..ea50f6e --- /dev/null +++ b/src/main/java/com/cczsa/xinghe/codegen/util/XResultCode.java @@ -0,0 +1,24 @@ +package com.cczsa.xinghe.codegen.util; + +import lombok.Getter; + +/** + * @author xia + * @date 2025/9/9 + * @version 0.0.1 + */ +@Getter +public enum XResultCode { + SUCCEED(200, "成功"), + FAILED(400, "失败"), + ; + + private final int code; + private final String message; + + XResultCode(int code, String message) { + this.code = code; + this.message = message; + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..d54486f --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,18 @@ +server: + port: 7011 + +spring: + datasource: + url: jdbc:postgresql://192.168.1.40:5432/xinghe-codegen + username: postgres + password: root + driver-class-name: org.postgresql.Driver + type: com.zaxxer.hikari.HikariDataSource # 使用 HikariCP 作为连接池 + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 60000 + idle-timeout: 300000 + max-lifetime: 1200000 + validation-timeout: 5000 + leak-detection-threshold: 60000 \ No newline at end of file