diff --git a/pom.xml b/pom.xml index 181e460b5e83c6e0e407741e7b508e13d01b3666..7217386cb271c23425aba55061a1879ff2a54014 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,30 @@ com.myjdbc.web myjdbc-web-orm - 3.1.0 - jar + 3.1.1 + 整合ORM框架,采用 Mybatis-Plus + Druid + Mysql + + + The Apache Software License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + 289222346@qq.com + Chen Wen + 289222346@qq.com + + + + scm:git:git://gitee.com/myjdbc-group/myjdbc-web-orm.git + scm:git:ssh://git@gitee.com/myjdbc-group/myjdbc-web-orm.git + https://gitee.com/myjdbc-group/myjdbc-web-orm + + + GitHub + https://gitee.com/myjdbc-group/myjdbc-web-orm/issues + diff --git a/src/main/java/com/myjdbc/common/controller/BaseController.java b/src/main/java/com/myjdbc/common/controller/BaseController.java index 93df5ef5d1dc9e6e3f617ea0aa36cb8eb17f6a15..7a0e5e5e971e6216b2965633ef2c3e5354e643d9 100644 --- a/src/main/java/com/myjdbc/common/controller/BaseController.java +++ b/src/main/java/com/myjdbc/common/controller/BaseController.java @@ -9,8 +9,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import com.baomidou.mybatisplus.core.metadata.IPage; import com.myjdbc.common.service.IBaseService; @@ -20,6 +18,9 @@ import com.myjdbc.web.core.model.ResultBody; import com.myjdbc.web.core.util.ResultUtil; import com.myjdbc.web.mp.model.BoTablePage; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + /** * 基础业务控制层 * @@ -50,12 +51,12 @@ public abstract class BaseController> { * 根据主键查询数据 * * @param id - * * @return */ + @Operation(summary = "根据主键查询单条数据", parameters = {@Parameter(name = "id", description = "唯一主键")}) @RequestResource(description = "主键查询") @GetMapping(value = "/{id}") - public ResultBody getById(@PathVariable("id") Serializable id) { + public ResultBody getById(@PathVariable("id") Serializable id) { try { T po = service.getById(id); return ResultUtil.createSuccess(po); @@ -69,12 +70,12 @@ public abstract class BaseController> { * 根据实体字段值完全匹配 * * @param page - * * @return */ + @Operation(summary = "批量查询") @RequestResource(description = "批量查询") - @RequestMapping(value = "/findAll", method = {RequestMethod.GET, RequestMethod.POST}) - public ResultBody findAll(@RequestBody BoTablePage page) { + @PostMapping("/findAll") + public ResultBody> findAll(@RequestBody BoTablePage page) { IPage iPage = service.page(page, page.getQuery()); return ResultUtil.createSuccess(iPage); } @@ -83,9 +84,9 @@ public abstract class BaseController> { * 新增数据操作 * * @param po - * * @return */ + @Operation(summary = "添加数据") @RequestResource(description = "添加数据") @PostMapping() public ResultBody add(@RequestBody T po) { @@ -96,9 +97,9 @@ public abstract class BaseController> { * 修改数据操作 * * @param po - * * @return */ + @Operation(summary = "修改数据") @RequestResource(description = "修改数据") @PutMapping() public ResultBody update(@RequestBody T po) { @@ -109,9 +110,9 @@ public abstract class BaseController> { * 删除数据操作 * * @param id - * * @return */ + @Operation(summary = "删除数据", parameters = {@Parameter(name = "id", description = "唯一主键")}) @RequestResource(description = "删除数据") @DeleteMapping("/{id}") public ResultBody delete(@PathVariable("id") Serializable id) { diff --git a/src/main/java/com/myjdbc/web/dropdown/model/DropDown.java b/src/main/java/com/myjdbc/web/dropdown/model/DropDown.java index f3421a46c082f8dc9e5fc65a3dbb00fdc358f35f..784de5a1df7ab2cf5368af8d9e8c106ebe52f1db 100644 --- a/src/main/java/com/myjdbc/web/dropdown/model/DropDown.java +++ b/src/main/java/com/myjdbc/web/dropdown/model/DropDown.java @@ -4,6 +4,8 @@ import java.util.List; import com.myjdbc.core.constant.SortConstant; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.Getter; import lombok.Setter; @@ -15,36 +17,43 @@ import lombok.Setter; */ @Getter @Setter +@Tag(name = "DropDown", description = "下拉列表实体") public class DropDown { /** * 下拉列表实际的值 */ + @Schema(description = "下拉列表实际的值") private String value; /** * 下拉列表显示的值 */ + @Schema(description = "下拉列表显示的值") private String name; /** * 是否已经选中 */ + @Schema(description = "是否已经选中") private boolean checked; /** * 上级Id */ + @Schema(description = "上级Id") private String parentId; /** * 子集 */ + @Schema(description = "子集") private List children; /** * 是否会被从前端传回 */ + @Schema(description = "是否会被从前端传回") private Boolean exist = true; /** @@ -52,5 +61,6 @@ public class DropDown { *

* 默认{@link SortConstant#DEFAULT_SERIAL_NUMBER} */ + @Schema(description = "排序序号(升序排列)") private Integer serialNumber = SortConstant.DEFAULT_SERIAL_NUMBER; } \ No newline at end of file diff --git a/src/main/java/com/myjdbc/web/mp/model/BoTablePage.java b/src/main/java/com/myjdbc/web/mp/model/BoTablePage.java index 7892c49e798a6fe8697ec4aa20c7802d24293bc5..8eb9d5dd32014f2056f8a4022965228cce2a9938 100644 --- a/src/main/java/com/myjdbc/web/mp/model/BoTablePage.java +++ b/src/main/java/com/myjdbc/web/mp/model/BoTablePage.java @@ -2,16 +2,20 @@ package com.myjdbc.web.mp.model; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.Getter; import lombok.Setter; /** - * Bootstrap-Table 分页 + * 带查询条件属性的分页实体 */ @Getter @Setter +@Tag(name = "BoTablePage", description = "分页查询业务实体") public class BoTablePage extends Page { + @Schema(description = "查询条件") private T query; } \ No newline at end of file diff --git a/src/main/resources/templates/entity.java.ftl b/src/main/resources/templates/entity.java.ftl new file mode 100644 index 0000000000000000000000000000000000000000..1258ee76acb0f31a97fb15a949c5ac45bf7c3aaa --- /dev/null +++ b/src/main/resources/templates/entity.java.ftl @@ -0,0 +1,155 @@ +package ${package.Entity}; + +<#list table.importPackages as pkg> +import ${pkg}; + + +<#if swagger> +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; + +<#if entityLombokModel> +import lombok.Getter; +import lombok.Setter; + <#if chainModel> +import lombok.experimental.Accessors; + + + +/** + *

+ * ${table.comment!} + *

+ * + * @author ${author} + * @since ${date} + */ +<#if entityLombokModel> +@Getter +@Setter + <#if chainModel> +@Accessors(chain = true) + + +<#if table.convert> +@TableName("${schemaName}${table.name}") + +<#if swagger> +@Tag(name = "${entity}对象", description = "${table.comment!}") + +<#if superEntityClass??> +public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}> { +<#elseif activeRecord> +public class ${entity} extends Model<${entity}> { +<#elseif entitySerialVersionUID> +public class ${entity} implements Serializable { +<#else> +public class ${entity} { + +<#if entitySerialVersionUID> + + private static final long serialVersionUID = 1L; + +<#-- ---------- BEGIN 字段循环遍历 ----------> +<#list table.fields as field> + <#if field.keyFlag> + <#assign keyPropertyName="${field.propertyName}"/> + + + <#if field.comment!?length gt 0> + <#if swagger> + @Schema(description = "${field.comment}") + <#else> + /** + * ${field.comment} + */ + + + <#if field.keyFlag> + <#-- 主键 --> + <#if field.keyIdentityFlag> + @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO) + <#elseif idType??> + @TableId(value = "${field.annotationColumnName}", type = IdType.${idType}) + <#elseif field.convert> + @TableId("${field.annotationColumnName}") + + <#-- 普通字段 --> + <#elseif field.fill??> + <#-- ----- 存在字段填充设置 -----> + <#if field.convert> + @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill}) + <#else> + @TableField(fill = FieldFill.${field.fill}) + + <#elseif field.convert> + @TableField("${field.annotationColumnName}") + + <#-- 乐观锁注解 --> + <#if field.versionField> + @Version + + <#-- 逻辑删除注解 --> + <#if field.logicDeleteField> + @TableLogic + + private ${field.propertyType} ${field.propertyName}; + +<#------------ END 字段循环遍历 ----------> + +<#if !entityLombokModel> + <#list table.fields as field> + <#if field.propertyType == "boolean"> + <#assign getprefix="is"/> + <#else> + <#assign getprefix="get"/> + + public ${field.propertyType} ${getprefix}${field.capitalName}() { + return ${field.propertyName}; + } + + <#if chainModel> + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + <#else> + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + + this.${field.propertyName} = ${field.propertyName}; + <#if chainModel> + return this; + + } + + + +<#if entityColumnConstant> + <#list table.fields as field> + public static final String ${field.name?upper_case} = "${field.name}"; + + + +<#if activeRecord> + @Override + public Serializable pkVal() { + <#if keyPropertyName??> + return this.${keyPropertyName}; + <#else> + return null; + + } + + +<#if !entityLombokModel> + @Override + public String toString() { + return "${entity}{" + + <#list table.fields as field> + <#if field_index==0> + "${field.propertyName}=" + ${field.propertyName} + + <#else> + ", ${field.propertyName}=" + ${field.propertyName} + + + + "}"; + } + +} \ No newline at end of file