修改代码生成器模板.
This commit is contained in:
@@ -15,7 +15,6 @@ import org.hibernate.validator.constraints.Range;
|
|||||||
@Data
|
@Data
|
||||||
public class PageRequest implements IPageRequest {
|
public class PageRequest implements IPageRequest {
|
||||||
|
|
||||||
// TODO TEST
|
|
||||||
@Range(min = 1, max = 10000)
|
@Range(min = 1, max = 10000)
|
||||||
@Schema(description = "页码")
|
@Schema(description = "页码")
|
||||||
private int page;
|
private int page;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.springframework.context.annotation.Bean;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* mybatis 配置类
|
* mybatis 配置类
|
||||||
* TODO 扫描的包
|
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class FieldFillHandler implements MetaObjectHandler {
|
|||||||
@Resource
|
@Resource
|
||||||
private SecurityHolder securityHolder;
|
private SecurityHolder securityHolder;
|
||||||
|
|
||||||
|
// TODO 删除fill baseConst
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertFill(MetaObject metaObject) {
|
public void insertFill(MetaObject metaObject) {
|
||||||
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) {
|
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) {
|
||||||
@@ -36,7 +38,6 @@ public class FieldFillHandler implements MetaObjectHandler {
|
|||||||
baseDO.setUpdateTime(now);
|
baseDO.setUpdateTime(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO TEST
|
|
||||||
Long userId = securityHolder.getLoginUserId();
|
Long userId = securityHolder.getLoginUserId();
|
||||||
// 创建人
|
// 创建人
|
||||||
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
|
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
|
||||||
@@ -60,7 +61,6 @@ public class FieldFillHandler implements MetaObjectHandler {
|
|||||||
|
|
||||||
// 更新人
|
// 更新人
|
||||||
Object updater = getFieldValByName("updater", metaObject);
|
Object updater = getFieldValByName("updater", metaObject);
|
||||||
// TODO TEST
|
|
||||||
Long userId = securityHolder.getLoginUserId();
|
Long userId = securityHolder.getLoginUserId();
|
||||||
if (Objects.nonNull(userId) && Objects.isNull(updater)) {
|
if (Objects.nonNull(userId) && Objects.isNull(updater)) {
|
||||||
setFieldValByName("updater", userId.toString(), metaObject);
|
setFieldValByName("updater", userId.toString(), metaObject);
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import com.orion.lang.utils.Strings;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO TEST
|
|
||||||
* <p>
|
|
||||||
* 有效性验证 wrapper
|
* 有效性验证 wrapper
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
@@ -38,22 +36,22 @@ public class ValidateLambdaWrapper<T> extends LambdaQueryWrapper<T> {
|
|||||||
for (Object object : objects) {
|
for (Object object : objects) {
|
||||||
// 非 null 检测
|
// 非 null 检测
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
// 字符串 非空校验
|
// 字符串 非空校验
|
||||||
if (object instanceof String) {
|
if (object instanceof String) {
|
||||||
if (Strings.isBlank((String) object)) {
|
if (Strings.isBlank((String) object)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 集合 非空校验
|
// 集合 非空校验
|
||||||
if (object instanceof Collection<?>) {
|
if (object instanceof Collection<?>) {
|
||||||
if (((Collection<?>) object).isEmpty()) {
|
if (((Collection<?>) object).isEmpty()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package ${package.Controller};
|
|||||||
import com.orion.lang.define.wrapper.DataGrid;
|
import com.orion.lang.define.wrapper.DataGrid;
|
||||||
import com.orion.ops.framework.common.annotation.RestWrapper;
|
import com.orion.ops.framework.common.annotation.RestWrapper;
|
||||||
import ${package.Service}.*;
|
import ${package.Service}.*;
|
||||||
#foreach($pkg in ${customFilePackages})
|
#foreach($pkg in ${customFilePackages})
|
||||||
import ${pkg}.*;
|
import ${pkg}.*;
|
||||||
#end
|
#end
|
||||||
#if(${superControllerClassPackage})
|
#if(${superControllerClassPackage})
|
||||||
import ${superControllerClassPackage};
|
import ${superControllerClassPackage};
|
||||||
#end
|
#end
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -40,61 +40,61 @@ public class ${table.controllerName} extends ${superControllerClass} {
|
|||||||
public class ${table.controllerName} {
|
public class ${table.controllerName} {
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ${type}Service ${typeLower}Service;
|
private ${type}Service ${typeLower}Service;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建$!{table.comment}")
|
@Operation(summary = "创建$!{table.comment}")
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:create')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:create')")
|
||||||
public Long create${type}(@Validated ${type}CreateRequest request){
|
public Long create${type}(@Validated @RequestBody ${type}CreateRequest request) {
|
||||||
return ${typeLower}Service.create${type}(request);
|
return ${typeLower}Service.create${type}(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新$!{table.comment}")
|
@Operation(summary = "更新$!{table.comment}")
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:update')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:update')")
|
||||||
public Integer update${type}(@Validated ${type}UpdateRequest request){
|
public Integer update${type}(@Validated @RequestBody ${type}UpdateRequest request) {
|
||||||
return ${typeLower}Service.update${type}(request);
|
return ${typeLower}Service.update${type}(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "通过id查询$!{table.comment}")
|
@Operation(summary = "通过id查询$!{table.comment}")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
||||||
public ${type}VO get${type}(@RequestParam("id") Long id){
|
public ${type}VO get${type}(@RequestParam("id") Long id) {
|
||||||
return ${typeLower}Service.get${type}(id);
|
return ${typeLower}Service.get${type}(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "通过id批量查询$!{table.comment}")
|
@Operation(summary = "通过id批量查询$!{table.comment}")
|
||||||
@Parameter(name = "idList", description = "idList", required = true)
|
@Parameter(name = "idList", description = "idList", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
||||||
public List<${type}VO> get${type}List(@RequestParam("idList") List<Long> idList){
|
public List<${type}VO> get${type}List(@RequestParam("idList") List<Long> idList) {
|
||||||
return ${typeLower}Service.get${type}List(idList);
|
return ${typeLower}Service.get${type}List(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
@Operation(summary = "分页查询$!{table.comment}")
|
@Operation(summary = "分页查询$!{table.comment}")
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
||||||
public DataGrid<${type}VO> get${type}Page(@Validated @RequestBody ${type}QueryRequest request){
|
public DataGrid<${type}VO> get${type}Page(@Validated @RequestBody ${type}QueryRequest request) {
|
||||||
return ${typeLower}Service.get${type}Page(request);
|
return ${typeLower}Service.get${type}Page(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/delete")
|
@PutMapping("/delete")
|
||||||
@Operation(summary = "删除$!{table.comment}")
|
@Operation(summary = "删除$!{table.comment}")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:delete')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:delete')")
|
||||||
public Integer delete${type}(@RequestParam("id") Long id){
|
public Integer delete${type}(@RequestParam("id") Long id) {
|
||||||
return ${typeLower}Service.delete${type}(id);
|
return ${typeLower}Service.delete${type}(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/delete-batch")
|
@PutMapping("/delete-batch")
|
||||||
@Operation(summary = "批量删除$!{table.comment}")
|
@Operation(summary = "批量删除$!{table.comment}")
|
||||||
@Parameter(name = "idList", description = "idList", required = true)
|
@Parameter(name = "idList", description = "idList", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:delete')")
|
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:delete')")
|
||||||
public Integer batchDelete${type}(@RequestParam("idList") List<Long> idList){
|
public Integer batchDelete${type}(@RequestParam("idList") List<Long> idList) {
|
||||||
return ${typeLower}Service.batchDelete${type}(idList);
|
return ${typeLower}Service.batchDelete${type}(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package ${currentPackage};
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
import ${package.Entity}.*;
|
import ${package.Entity}.*;
|
||||||
#foreach($pkg in ${customFilePackages})
|
#foreach($pkg in ${customFilePackages})
|
||||||
import ${pkg}.*;
|
import ${pkg}.*;
|
||||||
#end
|
#end
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,11 +19,11 @@ import java.util.List;
|
|||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public interface ${type}ProviderConvert {
|
public interface ${type}ProviderConvert {
|
||||||
|
|
||||||
${type}ProviderConvert MAPPER = Mappers.getMapper(${type}ProviderConvert.class);
|
${type}ProviderConvert MAPPER = Mappers.getMapper(${type}ProviderConvert.class);
|
||||||
|
|
||||||
${type}DO to(${type}DTO dto);
|
${type}DO to(${type}DTO dto);
|
||||||
|
|
||||||
${type}DTO to(${type}DO dto);
|
${type}DTO to(${type}DO dto);
|
||||||
|
|
||||||
List<${type}DO> toDO(List<${type}DTO> list);
|
List<${type}DO> toDO(List<${type}DTO> list);
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package ${currentPackage};
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
import ${package.Entity}.*;
|
import ${package.Entity}.*;
|
||||||
#foreach($pkg in ${customFilePackages})
|
#foreach($pkg in ${customFilePackages})
|
||||||
import ${pkg}.*;
|
import ${pkg}.*;
|
||||||
#end
|
#end
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,16 +18,16 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public interface ${type}Convert {
|
public interface ${type}Convert {
|
||||||
|
|
||||||
|
${type}Convert MAPPER = Mappers.getMapper(${type}Convert.class);
|
||||||
|
|
||||||
${type}Convert MAPPER = Mappers.getMapper(${type}Convert.class);
|
${type}DO to(${type}CreateRequest request);
|
||||||
|
|
||||||
${type}DO to(${type}CreateRequest request);
|
${type}DO to(${type}UpdateRequest request);
|
||||||
|
|
||||||
${type}DO to(${type}UpdateRequest request);
|
${type}DO to(${type}QueryRequest request);
|
||||||
|
|
||||||
${type}DO to(${type}QueryRequest request);
|
${type}VO to(${type}DO request);
|
||||||
|
|
||||||
${type}VO to(${type}DO request);
|
|
||||||
|
|
||||||
List<${type}VO> to(List<${type}DO> list);
|
List<${type}VO> to(List<${type}DO> list);
|
||||||
|
|
||||||
|
|||||||
@@ -26,52 +26,52 @@ import java.util.*;
|
|||||||
#if(${superEntityClass})
|
#if(${superEntityClass})
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
#elseif(${entitySerialVersionUID})
|
#elseif(${entitySerialVersionUID})
|
||||||
public class ${entity} implements Serializable{
|
public class ${entity} implements Serializable {
|
||||||
#else
|
#else
|
||||||
public class ${entity} {
|
public class ${entity} {
|
||||||
#end
|
#end
|
||||||
#if(${entitySerialVersionUID})
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
private static final long serialVersionUID=1L;
|
private static final long serialVersionUID = 1L;
|
||||||
#end
|
#end
|
||||||
## ---------- BEGIN 字段循环遍历 ----------
|
## ---------- BEGIN 字段循环遍历 ----------
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if(${field.keyFlag})
|
#if(${field.keyFlag})
|
||||||
#set($keyPropertyName=${field.propertyName})
|
#set($keyPropertyName=${field.propertyName})
|
||||||
#end
|
#end
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
#if(${field.keyFlag})
|
#if(${field.keyFlag})
|
||||||
## 主键
|
## 主键
|
||||||
#if(${field.keyIdentityFlag})
|
#if(${field.keyIdentityFlag})
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
||||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
||||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
||||||
#elseif(${field.convert})
|
#elseif(${field.convert})
|
||||||
@TableId("${field.annotationColumnName}")
|
@TableId("${field.annotationColumnName}")
|
||||||
#end
|
#end
|
||||||
## 普通字段
|
## 普通字段
|
||||||
#elseif(${field.fill})
|
#elseif(${field.fill})
|
||||||
## ----- 存在字段填充设置 -----
|
## ----- 存在字段填充设置 -----
|
||||||
#if(${field.convert})
|
#if(${field.convert})
|
||||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
||||||
#else
|
#else
|
||||||
@TableField(fill = FieldFill.${field.fill})
|
@TableField(fill = FieldFill.${field.fill})
|
||||||
#end
|
#end
|
||||||
#elseif(${field.convert})
|
#elseif(${field.convert})
|
||||||
@TableField("${field.annotationColumnName}")
|
@TableField("${field.annotationColumnName}")
|
||||||
#end
|
#end
|
||||||
## 乐观锁注解
|
## 乐观锁注解
|
||||||
#if(${field.versionField})
|
#if(${field.versionField})
|
||||||
@Version
|
@Version
|
||||||
#end
|
#end
|
||||||
## 逻辑删除注解
|
## 逻辑删除注解
|
||||||
#if(${field.logicDeleteField})
|
#if(${field.logicDeleteField})
|
||||||
@TableLogic
|
@TableLogic
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package ${currentPackage};
|
package ${currentPackage};
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -25,9 +23,9 @@ public class ${type}DTO implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package ${currentPackage};
|
package ${currentPackage};
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -26,9 +24,9 @@ import java.util.*;
|
|||||||
public class ${type}CreateRequest implements Serializable {
|
public class ${type}CreateRequest implements Serializable {
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import java.util.*;
|
|||||||
public class ${type}QueryRequest extends PageRequest {
|
public class ${type}QueryRequest extends PageRequest {
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package ${currentPackage};
|
package ${currentPackage};
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -26,9 +24,9 @@ import java.util.*;
|
|||||||
public class ${type}UpdateRequest implements Serializable {
|
public class ${type}UpdateRequest implements Serializable {
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package ${currentPackage};
|
package ${currentPackage};
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -25,9 +23,9 @@ public class ${type}VO implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
#if("$!field.comment" != "")
|
#if("$!field.comment" != "")
|
||||||
@Schema(description = "${field.comment}")
|
@Schema(description = "${field.comment}")
|
||||||
#end
|
#end
|
||||||
private ${field.propertyType} ${field.propertyName};
|
private ${field.propertyType} ${field.propertyName};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ import ${mapperAnnotationClass.name};
|
|||||||
#end
|
#end
|
||||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,38 +2,38 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||||
|
|
||||||
#if(${enableCache})
|
#if(${enableCache})
|
||||||
<!-- 开启二级缓存 -->
|
<!-- 开启二级缓存 -->
|
||||||
<cache type="${cacheClassName}"/>
|
<cache type="${cacheClassName}"/>
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if(${baseResultMap})
|
#if(${baseResultMap})
|
||||||
<!-- 通用查询映射结果 -->
|
<!-- 通用查询映射结果 -->
|
||||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
#if(${field.keyFlag})##生成主键排在第一位
|
#if(${field.keyFlag})##生成主键排在第一位
|
||||||
<id column="${field.name}" property="${field.propertyName}"/>
|
<id column="${field.name}" property="${field.propertyName}"/>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#foreach($field in ${table.commonFields})##生成公共字段
|
#foreach($field in ${table.commonFields})##生成公共字段
|
||||||
<result column="${field.name}" property="${field.propertyName}"/>
|
<result column="${field.name}" property="${field.propertyName}"/>
|
||||||
#end
|
#end
|
||||||
#foreach($field in ${table.fields})
|
#foreach($field in ${table.fields})
|
||||||
#if(!${field.keyFlag})##生成普通字段
|
#if(!${field.keyFlag})##生成普通字段
|
||||||
<result column="${field.name}" property="${field.propertyName}"/>
|
<result column="${field.name}" property="${field.propertyName}"/>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if(${baseColumnList})
|
#if(${baseColumnList})
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
#foreach($field in ${table.commonFields})
|
#foreach($field in ${table.commonFields})
|
||||||
${field.columnName},
|
${field.columnName},
|
||||||
#end
|
#end
|
||||||
${table.fieldNames}
|
${table.fieldNames}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
#end
|
#end
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import com.orion.lang.utils.collect.Lists;
|
|||||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.ops.framework.mybatis.core.query.Conditions;
|
import com.orion.ops.framework.mybatis.core.query.Conditions;
|
||||||
#foreach($pkg in ${customFilePackages})
|
#foreach($pkg in ${customFilePackages})
|
||||||
import ${pkg}.*;
|
import ${pkg}.*;
|
||||||
#end
|
#end
|
||||||
import ${package.Entity}.${entity};
|
import ${package.Entity}.${entity};
|
||||||
import ${package.Mapper}.${table.mapperName};
|
import ${package.Mapper}.${table.mapperName};
|
||||||
import ${package.Service}.${table.serviceName};
|
import ${package.Service}.${table.serviceName};
|
||||||
@@ -31,99 +31,97 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class ${table.serviceImplName} implements ${table.serviceName} {
|
public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||||
|
|
||||||
// TODO 需要自行实现 page 和 check 方法
|
// TODO 需要自行实现 page 和 check 方法
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ${type}DAO ${typeLower}DAO;
|
private ${type}DAO ${typeLower}DAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long create${type}(${type}CreateRequest request){
|
public Long create${type}(${type}CreateRequest request) {
|
||||||
// 转换
|
// 转换
|
||||||
${type}DO record= ${type}Convert.MAPPER.to(request);
|
${type}DO record = ${type}Convert.MAPPER.to(request);
|
||||||
record.setId(null);
|
record.setId(null);
|
||||||
// 查询是否存在
|
// 查询是否存在
|
||||||
if(this.check${type}Present(record)){
|
this.checkTestTablePresent(record);
|
||||||
throw ErrorCode.DATA_PRESENT.exception();
|
|
||||||
}
|
|
||||||
// 插入
|
// 插入
|
||||||
int effect= ${typeLower}DAO.insert(record);
|
int effect = ${typeLower}DAO.insert(record);
|
||||||
log.info("${type}Service-add${type} effect: {}, domain: {}",effect,JSON.toJSONString(record));
|
log.info("${type}Service-add${type} effect: {}, domain: {}", effect, JSON.toJSONString(record));
|
||||||
return record.getId();
|
return record.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer update${type}(${type}UpdateRequest request){
|
public Integer update${type}(${type}UpdateRequest request) {
|
||||||
// 转换
|
// 转换
|
||||||
${type}DO record= ${type}Convert.MAPPER.to(request);
|
${type}DO record = ${type}Convert.MAPPER.to(request);
|
||||||
Valid.notNull(request.getId(),ErrorMessage.ID_MISSING);
|
Valid.notNull(record.getId(), ErrorMessage.ID_MISSING);
|
||||||
// 查询是否存在
|
// 查询是否存在
|
||||||
if(this.check${type}Present(record)){
|
this.checkTestTablePresent(record);
|
||||||
throw ErrorCode.DATA_PRESENT.exception();
|
|
||||||
}
|
|
||||||
// 更新
|
// 更新
|
||||||
int effect= ${typeLower}DAO.updateById(record);
|
int effect = ${typeLower}DAO.updateById(record);
|
||||||
log.info("${type}Service-update${type} effect: {}, domain: {}",effect,JSON.toJSONString(record));
|
log.info("${type}Service-update${type} effect: {}, domain: {}", effect, JSON.toJSONString(record));
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ${type}VO get${type}(Long id){
|
public ${type}VO get${type}(Long id) {
|
||||||
// 查询
|
// 查询
|
||||||
${type}DO record= ${typeLower}DAO.selectById(id);
|
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||||
if(record==null){
|
if (record == null) {
|
||||||
throw ErrorCode.DATA_ABESENT.exception();
|
throw ErrorCode.DATA_ABESENT.exception();
|
||||||
}
|
}
|
||||||
// 转换
|
// 转换
|
||||||
return ${type}Convert.MAPPER.to(record);
|
return ${type}Convert.MAPPER.to(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<${type}VO> get${type}List(List<Long> idList){
|
public List<${type}VO> get${type}List(List<Long> idList) {
|
||||||
// 查询
|
// 查询
|
||||||
List<${type}DO> records= ${typeLower}DAO.selectBatchIds(idList);
|
List<${type}DO> records = ${typeLower}DAO.selectBatchIds(idList);
|
||||||
if(records.isEmpty()){
|
if (records.isEmpty()) {
|
||||||
return Lists.empty();
|
return Lists.empty();
|
||||||
}
|
}
|
||||||
// 转换
|
// 转换
|
||||||
return ${type}Convert.MAPPER.to(records);
|
return ${type}Convert.MAPPER.to(records);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request){
|
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request) {
|
||||||
// 构造条件
|
// 构造条件
|
||||||
LambdaQueryWrapper<${type}DO> wrapper=Conditions.wrapper(${type}DO.class);
|
LambdaQueryWrapper<${type}DO> wrapper = Conditions.wrapper(${type}DO.class);
|
||||||
// 查询
|
// 查询
|
||||||
return ${typeLower}DAO.of()
|
return ${typeLower}DAO.of()
|
||||||
.wrapper(wrapper)
|
.wrapper(wrapper)
|
||||||
.page(request)
|
.page(request)
|
||||||
.dataGrid(${type}Convert.MAPPER::to);
|
.dataGrid(${type}Convert.MAPPER::to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer delete${type}(Long id){
|
public Integer delete${type}(Long id) {
|
||||||
return ${typeLower}DAO.deleteById(id);
|
return ${typeLower}DAO.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer batchDelete${type}(List<Long> idList){
|
public Integer batchDelete${type}(List<Long> idList) {
|
||||||
return ${typeLower}DAO.deleteBatchIds(idList);
|
return ${typeLower}DAO.deleteBatchIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测对象是否存在
|
* 检测对象是否存在
|
||||||
*
|
*
|
||||||
* @param domain domain
|
* @param domain domain
|
||||||
* @return 是否存在
|
*/
|
||||||
*/
|
private void check${type}Present(${type}DO domain) {
|
||||||
private boolean check${type}Present(${type}DO domain){
|
|
||||||
// 构造条件
|
// 构造条件
|
||||||
LambdaQueryWrapper<${type}DO> wrapper=Conditions.wrapper(${type}DO.class)
|
LambdaQueryWrapper<${type}DO> wrapper = Conditions.wrapper(${type}DO.class)
|
||||||
.eq(${type}DO::getId,domain.getId());
|
.eq(${type}DO::getId, domain.getId());
|
||||||
// .eq(XXXDO::getXXX, domain.getXXX());
|
// .eq(XXXDO::getXXX, domain.getXXX());
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
return ${typeLower}DAO.of()
|
boolean present = testTableDAO.of()
|
||||||
.wrapper(wrapper)
|
.wrapper(wrapper)
|
||||||
.present();
|
.present();
|
||||||
|
if (present) {
|
||||||
|
throw ErrorCode.DATA_PRESENT.exception();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package ${package.Service};
|
package ${package.Service};
|
||||||
|
|
||||||
import com.orion.lang.define.wrapper.DataGrid;
|
import com.orion.lang.define.wrapper.DataGrid;
|
||||||
#foreach($pkg in ${customFilePackages})
|
#foreach($pkg in ${customFilePackages})
|
||||||
import ${pkg}.*;
|
import ${pkg}.*;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,60 +16,60 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface ${table.serviceName} {
|
public interface ${table.serviceName} {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入$!{table.comment}
|
* 插入$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
Long create${type}(${type}CreateRequest request);
|
Long create${type}(${type}CreateRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 id 更新$!{table.comment}
|
* 通过 id 更新$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return effect
|
* @return effect
|
||||||
*/
|
*/
|
||||||
Integer update${type}(${type}UpdateRequest request);
|
Integer update${type}(${type}UpdateRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 id 查询$!{table.comment}
|
* 通过 id 查询$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param id id
|
* @param id id
|
||||||
* @return row
|
* @return row
|
||||||
*/
|
*/
|
||||||
${type}VO get${type}(Long id);
|
${type}VO get${type}(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 id 批量查询$!{table.comment}
|
* 通过 id 批量查询$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param idList idList
|
* @param idList idList
|
||||||
* @return rows
|
* @return rows
|
||||||
*/
|
*/
|
||||||
List<${type}VO> get${type}List(List<Long> idList);
|
List<${type}VO> get${type}List(List<Long> idList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询$!{table.comment}
|
* 分页查询$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return rows
|
* @return rows
|
||||||
*/
|
*/
|
||||||
DataGrid<${type}VO> get${type}Page(${type}QueryRequest request);
|
DataGrid<${type}VO> get${type}Page(${type}QueryRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 id 删除$!{table.comment}
|
* 通过 id 删除$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param id id
|
* @param id id
|
||||||
* @return effect
|
* @return effect
|
||||||
*/
|
*/
|
||||||
Integer delete${type}(Long id);
|
Integer delete${type}(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 id 批量删除$!{table.comment}
|
* 通过 id 批量删除$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param idList idList
|
* @param idList idList
|
||||||
* @return effect
|
* @return effect
|
||||||
*/
|
*/
|
||||||
Integer batchDelete${type}(List<Long> idList);
|
Integer batchDelete${type}(List<Long> idList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class OrionSwaggerAutoConfiguration {
|
|||||||
Map<String, SecurityScheme> securitySchemas = this.buildSecuritySchemes();
|
Map<String, SecurityScheme> securitySchemas = this.buildSecuritySchemes();
|
||||||
OpenAPI api = new OpenAPI()
|
OpenAPI api = new OpenAPI()
|
||||||
// 接口信息
|
// 接口信息
|
||||||
.info(buildInfo(properties))
|
.info(this.buildInfo(properties))
|
||||||
// 接口安全配置
|
// 接口安全配置
|
||||||
.components(new Components().securitySchemes(securitySchemas));
|
.components(new Components().securitySchemes(securitySchemas));
|
||||||
securitySchemas.keySet()
|
securitySchemas.keySet()
|
||||||
@@ -109,13 +109,12 @@ public class OrionSwaggerAutoConfiguration {
|
|||||||
propertyResolverUtils, openApiBuilderCustomizers, serverBaseUrlCustomizers, javadocProvider);
|
propertyResolverUtils, openApiBuilderCustomizers, serverBaseUrlCustomizers, javadocProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 所有模块的 api 分组
|
* @return 所有模块的 api 分组
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public GroupedOpenApi allGroupedOpenApi() {
|
public GroupedOpenApi allGroupedOpenApi() {
|
||||||
return buildGroupedOpenApi("全部", "");
|
return buildGroupedOpenApi("全部", "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class GlobalExceptionHandler {
|
|||||||
@ExceptionHandler(value = BindException.class)
|
@ExceptionHandler(value = BindException.class)
|
||||||
public HttpWrapper<?> paramBindExceptionHandler(BindException ex) {
|
public HttpWrapper<?> paramBindExceptionHandler(BindException ex) {
|
||||||
log.error("paramBindExceptionHandler", ex);
|
log.error("paramBindExceptionHandler", ex);
|
||||||
FieldError error = ex.getFieldError();
|
FieldError error = Objects.requireNonNull(ex.getFieldError());
|
||||||
return ErrorCode.BAD_REQUEST.wrapper().msg(Objects.requireNonNull(error).getDefaultMessage());
|
return ErrorCode.BAD_REQUEST.wrapper().msg(error.getField() + " " + error.getDefaultMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(value = ConstraintViolationException.class)
|
@ExceptionHandler(value = ConstraintViolationException.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user