fix: 自动代码生成错误问题修复
This commit is contained in:
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
|||||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||||
import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
|
import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,14 +36,16 @@ public class FastAutoGeneratorTest {
|
|||||||
;
|
;
|
||||||
})
|
})
|
||||||
// 包配置
|
// 包配置
|
||||||
.packageConfig(builder -> builder
|
.packageConfig(builder -> {
|
||||||
.parent("com.youlai.system")
|
builder
|
||||||
.entity("model.entity")
|
.parent("com.youlai.system")
|
||||||
.mapper("mapper")
|
.entity("model.entity")
|
||||||
.service("service")
|
.mapper("mapper")
|
||||||
.serviceImpl("service.impl")
|
.service("service")
|
||||||
.controller("controller")
|
.serviceImpl("service.impl")
|
||||||
.pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper"))
|
.controller("controller")
|
||||||
|
.pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper"));
|
||||||
|
}
|
||||||
)
|
)
|
||||||
// 注入配置(设置扩展类的模板路径和包路径)
|
// 注入配置(设置扩展类的模板路径和包路径)
|
||||||
.injectionConfig(consumer -> {
|
.injectionConfig(consumer -> {
|
||||||
@@ -53,6 +54,7 @@ public class FastAutoGeneratorTest {
|
|||||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/vo.java.vm").packageName("model.vo").build());
|
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/vo.java.vm").packageName("model.vo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/bo.java.vm").packageName("model.bo").build());
|
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/bo.java.vm").packageName("model.bo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/pageQuery.java.vm").packageName("model.query").build());
|
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/pageQuery.java.vm").packageName("model.query").build());
|
||||||
|
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/pageVO.java.vm").packageName("model.vo").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/form.java.vm").packageName("model.form").build());
|
customFiles.add(new CustomFile.Builder().fileName("Form.java").templatePath("/templates/form.java.vm").packageName("model.form").build());
|
||||||
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/converter.java.vm").packageName("converter").build());
|
customFiles.add(new CustomFile.Builder().fileName("Converter.java").templatePath("/templates/converter.java.vm").packageName("converter").build());
|
||||||
consumer.customFile(customFiles);
|
consumer.customFile(customFiles);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ${package.Entity};
|
package ${package.Parent}.model.bo;
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
#foreach($pkg in ${table.importPackages})
|
||||||
import ${pkg};
|
import ${pkg};
|
||||||
@@ -24,17 +24,14 @@ import lombok.experimental.Accessors;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if(${table.convert})
|
|
||||||
@TableName("${schemaName}${table.name}")
|
|
||||||
#end
|
|
||||||
#if(${superEntityClass})
|
#if(${superEntityClass})
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
public class ${entity}BO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
#elseif(${activeRecord})
|
#elseif(${activeRecord})
|
||||||
public class ${entity} extends Model<${entity}> {
|
public class ${entity}BO extends Model<${entity}> {
|
||||||
#elseif(${entitySerialVersionUID})
|
#elseif(${entitySerialVersionUID})
|
||||||
public class ${entity} implements Serializable {
|
public class ${entity}BO implements Serializable {
|
||||||
#else
|
#else
|
||||||
public class ${entity} {
|
public class ${entity}BO {
|
||||||
#end
|
#end
|
||||||
#if(${entitySerialVersionUID})
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package ${package.Controller};
|
package ${package.Controller};
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
#if(${restControllerStyle})
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
#else
|
import ${package.Parent}.model.form.${entity}Form;
|
||||||
import org.springframework.stereotype.Controller;
|
import ${package.Parent}.model.query.${entity}PageQuery;
|
||||||
#end
|
import ${package.Parent}.model.vo.${entity}PageVO;
|
||||||
|
import ${package.Parent}.service.${entity}Service;
|
||||||
#if(${superControllerClassPackage})
|
#if(${superControllerClassPackage})
|
||||||
import ${superControllerClassPackage};
|
import ${superControllerClassPackage};
|
||||||
#end
|
#end
|
||||||
@@ -13,24 +14,58 @@ import ${superControllerClassPackage};
|
|||||||
/**
|
/**
|
||||||
* $!{table.comment} 前端控制器
|
* $!{table.comment} 前端控制器
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author${author}
|
||||||
* @since ${date}
|
* @since${date}
|
||||||
*/
|
*/
|
||||||
#if(${restControllerStyle})
|
|
||||||
@RestController
|
@RestController
|
||||||
#else
|
@RequiredArgsConstructor
|
||||||
@Controller
|
|
||||||
#end
|
|
||||||
@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
|
|
||||||
|
|
||||||
#if(${superControllerClass})
|
#if(${superControllerClass})
|
||||||
public class ${table.controllerName} extends ${superControllerClass} {
|
public class${table.controllerName} extends ${superControllerClass} {
|
||||||
#else
|
#else
|
||||||
public class ${table.controllerName} {
|
public class ${table.controllerName} {
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#set($entityLower = $string.toLowerCase($entity))
|
||||||
|
private final ${entity}Service $entityLowerService;
|
||||||
|
|
||||||
|
@Operation(summary = "$!{table.comment}分页列表")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public PageResult<${entity}PageVO> listPaged${entity}s(${entity}PageQuery queryParams ) {
|
||||||
|
IPage<${entity}PageVO> result = ${entityLower}Service.listPaged${entity}s(queryParams);
|
||||||
|
return PageResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增$!{table.comment}")
|
||||||
|
@PostMapping
|
||||||
|
@PreventDuplicateSubmit
|
||||||
|
public Result save${entity}(@RequestBody @Valid ${entity}Form formData ) {
|
||||||
|
boolean result = ${entityLower}Service.save${entity}(userForm);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "$!{table.comment}表单数据")
|
||||||
|
@GetMapping("/{id}/form")
|
||||||
|
public Result<${entity}Form> get${entity}Form(
|
||||||
|
@Parameter(description = "$!{table.comment}ID") @PathVariable Long id
|
||||||
|
) {
|
||||||
|
${entity}Form formData = ${entityLower}Service.get${entity}FormData(id);
|
||||||
|
return Result.success(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改$!{table.comment}")
|
||||||
|
@PutMapping(value = "/{id}")
|
||||||
|
public Result update${entity}(@Parameter(description = "$!{table.comment}ID") @PathVariable Long id,
|
||||||
|
@RequestBody @Validated ${entity}Form formData) {
|
||||||
|
boolean result = ${entityLower}Service.update${entity}(userId, formData);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除$!{table.comment}")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result delete${entity}s(
|
||||||
|
@Parameter(description = "$!{table.comment}ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||||
|
) {
|
||||||
|
boolean result = ${entityLower}Service.delete${entity}s(ids);
|
||||||
|
return Result.judge(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,17 @@
|
|||||||
package ${package}.converter;
|
package ${package.Parent}.converter;
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
import org.mapstruct.InheritInverseConfiguration;
|
import org.mapstruct.InheritInverseConfiguration;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.mapstruct.Mappings;
|
|
||||||
|
|
||||||
import ${package}.dto.${entity}DTO;
|
|
||||||
import ${package}.entity.${entity};
|
|
||||||
import ${package}.vo.${entity}PageVO;
|
|
||||||
import ${package}.form.${entity}Form;
|
|
||||||
import ${package}.bo.${entity}BO;
|
|
||||||
|
|
||||||
|
import ${package.Parent}.model.dto.${entity}DTO;
|
||||||
|
import ${package.Parent}.model.entity.${entity};
|
||||||
|
import ${package.Parent}.model.vo.${entity}PageVO;
|
||||||
|
import ${package.Parent}.model.form.${entity}Form;
|
||||||
|
import ${package.Parent}.model.bo.${entity}BO;
|
||||||
|
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface ${entity}Converter}{
|
public interface ${entity}Converter{
|
||||||
|
|
||||||
${entity}PageVO bo2PageVo(${entity}BO bo);
|
${entity}PageVO bo2PageVo(${entity}BO bo);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package ${package}.model.dto;
|
package ${package.Parent}.model.dto;
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
|
||||||
import ${pkg};
|
|
||||||
#end
|
|
||||||
#if(${springdoc})
|
#if(${springdoc})
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
#elseif(${swagger})
|
#elseif(${swagger})
|
||||||
@@ -16,7 +13,7 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
import java.io.Serializable;
|
||||||
/**
|
/**
|
||||||
* $!{table.comment} DTO
|
* $!{table.comment} DTO
|
||||||
*
|
*
|
||||||
@@ -27,25 +24,22 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
#if(${chainModel})
|
#if(${chainModel})
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if(${table.convert})
|
|
||||||
@TableName("${schemaName}${table.name}")
|
|
||||||
#end
|
|
||||||
#if(${springdoc})
|
#if(${springdoc})
|
||||||
@Schema(name = "${entity}", description = "$!{table.comment}")
|
@Schema(name = "${entity}", description = "$!{table.comment}")
|
||||||
#elseif(${swagger})
|
#elseif(${swagger})
|
||||||
@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
|
@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
|
||||||
#end
|
#end
|
||||||
#if(${superEntityClass})
|
#if(${superEntityClass})
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
public class ${entity}DTO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
#elseif(${activeRecord})
|
#elseif(${activeRecord})
|
||||||
public class ${entity} extends Model<${entity}> {
|
public class ${entity}DTO extends Model<${entity}> {
|
||||||
#elseif(${entitySerialVersionUID})
|
#elseif(${entitySerialVersionUID})
|
||||||
public class ${entity} implements Serializable {
|
public class ${entity}DTO implements Serializable {
|
||||||
#else
|
#else
|
||||||
public class ${entity} {
|
public class ${entity}DTO {
|
||||||
#end
|
#end
|
||||||
#if(${entitySerialVersionUID})
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ${package}.model.dto;
|
package ${package.Parent}.model.form;
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
#foreach($pkg in ${table.importPackages})
|
||||||
import ${pkg};
|
import ${pkg};
|
||||||
@@ -30,22 +30,19 @@ import lombok.Setter;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if(${table.convert})
|
|
||||||
@TableName("${schemaName}${table.name}")
|
|
||||||
#end
|
|
||||||
#if(${springdoc})
|
#if(${springdoc})
|
||||||
@Schema(name = "${entity}", description = "$!{table.comment}")
|
@Schema(name = "${entity}", description = "$!{table.comment}")
|
||||||
#elseif(${swagger})
|
#elseif(${swagger})
|
||||||
@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
|
@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
|
||||||
#end
|
#end
|
||||||
#if(${superEntityClass})
|
#if(${superEntityClass})
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
public class ${entity}Form extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
#elseif(${activeRecord})
|
#elseif(${activeRecord})
|
||||||
public class ${entity} extends Model<${entity}> {
|
public class ${entity}Form extends Model<${entity}> {
|
||||||
#elseif(${entitySerialVersionUID})
|
#elseif(${entitySerialVersionUID})
|
||||||
public class ${entity} implements Serializable {
|
public class ${entity}Form implements Serializable {
|
||||||
#else
|
#else
|
||||||
public class ${entity} {
|
public class ${entity}Form {
|
||||||
#end
|
#end
|
||||||
#if(${entitySerialVersionUID})
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import ${superMapperClassPackage};
|
|||||||
import ${mapperAnnotationClass.name};
|
import ${mapperAnnotationClass.name};
|
||||||
#end
|
#end
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import ${package.Parent}.model.bo.${entity}BO;
|
||||||
|
import ${package.Parent}.model.query.${entity}PageQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{table.comment} Mapper 接口
|
* $!{table.comment} Mapper 接口
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package ${package}.model.query;
|
package ${package.Parent}.model.query;
|
||||||
|
|
||||||
import ${package}.common.base.BasePageQuery;
|
import ${package.Parent}.common.base.BasePageQuery;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|||||||
130
src/test/resources/templates/pageVo.java.vm
Normal file
130
src/test/resources/templates/pageVo.java.vm
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
package ${package.Parent}.model.vo;
|
||||||
|
|
||||||
|
#foreach($pkg in ${table.importPackages})
|
||||||
|
import ${pkg};
|
||||||
|
#end
|
||||||
|
#if(${springdoc})
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#elseif(${swagger})
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(${entityLombokModel})
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
#if(${chainModel})
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $!{table.comment} 分页VO
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
#if(${entityLombokModel})
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
#if(${chainModel})
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(${springdoc})
|
||||||
|
@Schema(name = "${entity}", description = "$!{table.comment}")
|
||||||
|
#elseif(${swagger})
|
||||||
|
@ApiModel(value = "${entity}分页视图对象", description = "$!{table.comment}")
|
||||||
|
#end
|
||||||
|
#if(${superEntityClass})
|
||||||
|
public class ${entity}PageVO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
|
#elseif(${activeRecord})
|
||||||
|
public class ${entity}PageVO extends Model<${entity}> {
|
||||||
|
#elseif(${entitySerialVersionUID})
|
||||||
|
public class ${entity}PageVO implements Serializable {
|
||||||
|
#else
|
||||||
|
public class ${entity}PageVO {
|
||||||
|
#end
|
||||||
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
#end
|
||||||
|
## ---------- BEGIN 字段循环遍历 ----------
|
||||||
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
|
#if(${field.keyFlag})
|
||||||
|
#set($keyPropertyName=${field.propertyName})
|
||||||
|
#end
|
||||||
|
#if("$!field.comment" != "")
|
||||||
|
#if(${springdoc})
|
||||||
|
@Schema(description = "${field.comment}")
|
||||||
|
#elseif(${swagger})
|
||||||
|
@ApiModelProperty("${field.comment}")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* ${field.comment}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
private ${field.propertyType} ${field.propertyName};
|
||||||
|
#end
|
||||||
|
## ---------- END 字段循环遍历 ----------
|
||||||
|
#if(!${entityLombokModel})
|
||||||
|
#foreach($field in ${table.fields})
|
||||||
|
#if(${field.propertyType.equals("boolean")})
|
||||||
|
#set($getprefix="is")
|
||||||
|
#else
|
||||||
|
#set($getprefix="get")
|
||||||
|
#end
|
||||||
|
|
||||||
|
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}) {
|
||||||
|
#end
|
||||||
|
this.${field.propertyName} = ${field.propertyName};
|
||||||
|
#if(${chainModel})
|
||||||
|
return this;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
## --foreach end---
|
||||||
|
#end
|
||||||
|
## --end of #if(!${entityLombokModel})--
|
||||||
|
#if(${entityColumnConstant})
|
||||||
|
#foreach($field in ${table.fields})
|
||||||
|
|
||||||
|
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(${activeRecord})
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable pkVal() {
|
||||||
|
#if(${keyPropertyName})
|
||||||
|
return this.${keyPropertyName};
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#if(!${entityLombokModel})
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "${entity}{" +
|
||||||
|
#foreach($field in ${table.fields})
|
||||||
|
#if($!{foreach.index}==0)
|
||||||
|
"${field.propertyName} = " + ${field.propertyName} +
|
||||||
|
#else
|
||||||
|
", ${field.propertyName} = " + ${field.propertyName} +
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
}
|
||||||
@@ -2,14 +2,17 @@ package ${package.Service};
|
|||||||
|
|
||||||
import ${package.Entity}.${entity};
|
import ${package.Entity}.${entity};
|
||||||
import ${superServiceClassPackage};
|
import ${superServiceClassPackage};
|
||||||
|
import ${package.Parent}.model.form.${entity}Form;
|
||||||
|
import ${package.Parent}.model.query.${entity}PageQuery;
|
||||||
|
import ${package.Parent}.model.vo.${entity}PageVO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
/**
|
/**
|
||||||
* $!{table.comment} 服务类
|
* $!{table.comment} 服务类
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
*/
|
*/
|
||||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
public interface ${entity}Service extends ${superServiceClass}<${entity}> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +47,7 @@ public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
|||||||
* @param formData $!{table.comment}表单对象
|
* @param formData $!{table.comment}表单对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean update${entity}(Long id, UserForm formData);
|
boolean update${entity}(Long id, ${entity}Form formData);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,19 @@ import ${superServiceImplClassPackage};
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.youlai.system.common.util.DateUtils;
|
import com.youlai.system.common.util.DateUtils;
|
||||||
|
import ${package.Parent}.model.form.${entity}Form;
|
||||||
|
import ${package.Parent}.model.query.${entity}PageQuery;
|
||||||
|
import ${package.Parent}.model.bo.${entity}BO;
|
||||||
|
import ${package.Parent}.model.vo.${entity}PageVO;
|
||||||
|
import ${package.Parent}.converter.${entity}Converter;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $!{table.comment} 服务实现类
|
* $!{table.comment} 服务实现类
|
||||||
@@ -47,12 +60,13 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
|
|||||||
/**
|
/**
|
||||||
* 获取$!{table.comment}表单数据
|
* 获取$!{table.comment}表单数据
|
||||||
*
|
*
|
||||||
* @param userId $!{table.comment}ID
|
* @param id $!{table.comment}ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ${entity}Form get${entity}FormData(Long userId) {
|
public ${entity}Form get${entity}FormData(Long id) {
|
||||||
return this.baseMapper.get${entity}FormData(userId);
|
${entity} entity = this.getById(id);
|
||||||
|
return converter.entity2Form(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,19 +78,18 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
|
|||||||
@Override
|
@Override
|
||||||
public boolean save${entity}(${entity}Form formData) {
|
public boolean save${entity}(${entity}Form formData) {
|
||||||
// 实体转换 form->entity
|
// 实体转换 form->entity
|
||||||
SysUser entity = converter.form2Entity(formData);
|
${entity} entity = converter.form2Entity(formData);
|
||||||
return this.save(entity);
|
return this.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新$!{table.comment}
|
* 更新$!{table.comment}
|
||||||
*
|
*
|
||||||
* @param userId $!{table.comment}ID
|
* @param id $!{table.comment}ID
|
||||||
* @param formData $!{table.comment}表单对象
|
* @param formData $!{table.comment}表单对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public boolean update${entity}(Long id,${entity}Form formData) {
|
public boolean update${entity}(Long id,${entity}Form formData) {
|
||||||
${entity} entity = converter.form2Entity(formData);
|
${entity} entity = converter.form2Entity(formData);
|
||||||
return this.updateById(entity);
|
return this.updateById(entity);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ${package}.model.vo;
|
package ${package.Parent}.model.vo;
|
||||||
|
|
||||||
#foreach($pkg in ${table.importPackages})
|
#foreach($pkg in ${table.importPackages})
|
||||||
import ${pkg};
|
import ${pkg};
|
||||||
@@ -30,22 +30,19 @@ import lombok.Setter;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if(${table.convert})
|
|
||||||
@TableName("${schemaName}${table.name}")
|
|
||||||
#end
|
|
||||||
#if(${springdoc})
|
#if(${springdoc})
|
||||||
@Schema(name = "${entity}", description = "$!{table.comment}")
|
@Schema(name = "${entity}", description = "$!{table.comment}")
|
||||||
#elseif(${swagger})
|
#elseif(${swagger})
|
||||||
@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
|
@ApiModel(value = "${entity}视图对象", description = "$!{table.comment}")
|
||||||
#end
|
#end
|
||||||
#if(${superEntityClass})
|
#if(${superEntityClass})
|
||||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
public class ${entity}VO extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||||
#elseif(${activeRecord})
|
#elseif(${activeRecord})
|
||||||
public class ${entity} extends Model<${entity}> {
|
public class ${entity} extends Model<${entity}> {
|
||||||
#elseif(${entitySerialVersionUID})
|
#elseif(${entitySerialVersionUID})
|
||||||
public class ${entity} implements Serializable {
|
public class ${entity}VO implements Serializable {
|
||||||
#else
|
#else
|
||||||
public class ${entity} {
|
public class ${entity}VO {
|
||||||
#end
|
#end
|
||||||
#if(${entitySerialVersionUID})
|
#if(${entitySerialVersionUID})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user