initial commit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package ${cfg.clientPackage};
|
||||
|
||||
import com.msph.cls.base.model.rest.RestResult;
|
||||
import ${cfg.paramPackage}.${entity}${cfg.addParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.updateParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.queryParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.voSuffix};
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.msph.cls.base.model.pojo.PageDataInfo;
|
||||
|
||||
/**
|
||||
* ${table.comment!}客户端
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
@FeignClient(name = "${cfg.appName}", path = "${cfg.appContextPath}", contextId = "${entity}Client")
|
||||
@RequestMapping("<#if package.ModuleName??>/client/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>client/${controllerMappingHyphen}<#else>client/${table.entityPath}</#if>")
|
||||
public interface ${entity}${cfg.clientSuffix} {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param params 新增对象
|
||||
* @return 统一响应对象
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增")
|
||||
RestResult<Void> add${entity}(@RequestBody ${entity}${cfg.addParamsSuffix} params);
|
||||
|
||||
/**
|
||||
* 删除,对象使用了@TableLogic注解时,为逻辑删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 统一响应对象
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
@ApiOperation("删除")
|
||||
RestResult<Void> delete${entity}(@PathVariable(value = "id") long id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param params 修改对象
|
||||
* @return 统一响应对象
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
RestResult<Void> update${entity}(@RequestBody ${entity}${cfg.updateParamsSuffix} params);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 统一响应对象
|
||||
*/
|
||||
@GetMapping("/detail/{id}")
|
||||
@ApiOperation("详情")
|
||||
RestResult<${entity}${cfg.voSuffix}> get${entity}(@PathVariable(value = "id") long id);
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*
|
||||
* @param params 查询对象
|
||||
* @return 统一响应对象
|
||||
*/
|
||||
@PostMapping("/listPage")
|
||||
@ApiOperation("分页列表")
|
||||
RestResult<PageDataInfo<${entity}${cfg.voSuffix}>> list${entity}Page(@RequestBody ${entity}${cfg.queryParamsSuffix} params);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package ${package.Controller};
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ${cfg.clientPackage}.${entity}${cfg.clientSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.addParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.updateParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.queryParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.voSuffix};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.msph.cls.base.model.pojo.PageDataInfo;
|
||||
import com.msph.cls.base.model.rest.RestResult;
|
||||
|
||||
/**
|
||||
* ${table.comment!}控制层
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
@Api(tags = "${table.comment}")
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class ${table.controllerName} implements ${entity}${cfg.clientSuffix} {
|
||||
|
||||
<#assign serviceInstanceName="${table.entityPath}Service" />
|
||||
@Autowired
|
||||
private ${table.serviceName} ${serviceInstanceName};
|
||||
|
||||
@Override
|
||||
public RestResult<Void> add${entity}(@RequestBody ${entity}${cfg.addParamsSuffix} params) {
|
||||
${serviceInstanceName}.save${entity}(params);
|
||||
return RestResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResult<Void> delete${entity}(@PathVariable long id) {
|
||||
${serviceInstanceName}.removeById(id);
|
||||
return RestResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResult<Void> update${entity}(@RequestBody ${entity}${cfg.updateParamsSuffix} params) {
|
||||
${serviceInstanceName}.update${entity}(params);
|
||||
return RestResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResult<${entity}${cfg.voSuffix}> get${entity}(@PathVariable long id) {
|
||||
${entity}${cfg.doSuffix} data = ${serviceInstanceName}.getById(id);
|
||||
if (data == null) return RestResult.success();
|
||||
${entity}${cfg.voSuffix} result = new ${entity}${cfg.voSuffix}();
|
||||
BeanUtils.copyProperties(data, result);
|
||||
return RestResult.success(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResult<PageDataInfo<${entity}${cfg.voSuffix}>> list${entity}Page(@RequestBody ${entity}${cfg.queryParamsSuffix} params) {
|
||||
PageDataInfo<${entity}${cfg.voSuffix}> data = ${serviceInstanceName}.list${entity}Page(params);
|
||||
return RestResult.success(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package ${package.Entity};
|
||||
|
||||
<#list table.importPackages as pkg>
|
||||
import ${pkg};
|
||||
</#list>
|
||||
<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>
|
||||
<#if table.convert>
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
<#if superEntityClass??>
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
</#if>
|
||||
import lombok.experimental.Accessors;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if superEntityClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
@Accessors(chain = true)
|
||||
</#if>
|
||||
<#if table.convert>
|
||||
@TableName("${table.name}")
|
||||
</#if>
|
||||
<#if swagger2>
|
||||
@ApiModel(value = "${entity}对象", description = "${table.comment!}")
|
||||
<#else>
|
||||
/**
|
||||
* ${entity}对象 description=${table.comment!}
|
||||
*/
|
||||
</#if>
|
||||
<#if superEntityClass??>
|
||||
public class ${entity} extends ${superEntityClass} <#if activeRecord><${entity}></#if> {
|
||||
<#elseif activeRecord>
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
<#else>
|
||||
public class ${entity} implements Serializable {
|
||||
</#if>
|
||||
<#if entitySerialVersionUID>
|
||||
private static final long serialVersionUID = 1L;
|
||||
</#if>
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
</#if>
|
||||
</#if>
|
||||
<#if field.keyFlag>
|
||||
<#-- 主键 -->
|
||||
<#if field.keyIdentityFlag>
|
||||
@TableId(value = "${field.name}", type = IdType.AUTO)
|
||||
<#elseif idType??>
|
||||
@TableId(value = "${field.name}", type = IdType.${idType})
|
||||
<#elseif field.convert>
|
||||
@TableId("${field.name}")
|
||||
</#if>
|
||||
<#-- 普通字段 -->
|
||||
<#elseif field.fill??>
|
||||
<#-- ----- 存在字段填充设置 ----->
|
||||
<#if field.convert>
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
<#else>
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
</#if>
|
||||
<#elseif field.convert>
|
||||
@TableField("${field.name}")
|
||||
</#if>
|
||||
<#-- 乐观锁注解 -->
|
||||
<#if (versionFieldName!"") == field.name>
|
||||
@Version
|
||||
</#if>
|
||||
<#-- 逻辑删除注解 -->
|
||||
<#if (logicDeleteFieldName!"") == field.name>
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#if entityColumnConstant>
|
||||
|
||||
<#list table.fields as field>
|
||||
public static final String ${field.name?upper_case} = "${field.name}";
|
||||
</#list>
|
||||
</#if>
|
||||
<#if activeRecord>
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
<#if keyPropertyName??>
|
||||
return this.${keyPropertyName};
|
||||
<#else>
|
||||
return null;
|
||||
</#if>
|
||||
}
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package ${cfg.paramPackage};
|
||||
|
||||
<#--<#list table.importPackages as pkg>-->
|
||||
<#--import ${pkg};-->
|
||||
<#--</#list>-->
|
||||
<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if cfg.superOpsParamsClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
</#if>
|
||||
<#if swagger2>
|
||||
@ApiModel(value = "${entity}新增对象", description = "${table.comment!}")
|
||||
</#if>
|
||||
public class ${entity}${cfg.addParamsSuffix} implements Serializable {
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
<#--逻辑删除字段不生成-->
|
||||
<#if (logicDeleteFieldName!"") != field.name>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
</#if>
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#if>
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package ${package.Entity};
|
||||
|
||||
<#list table.importPackages as pkg>
|
||||
import ${pkg};
|
||||
</#list>
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
<#--<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>-->
|
||||
<#if table.convert>
|
||||
<#--import com.baomidou.mybatisplus.annotation.convertconvert;-->
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
<#if superEntityClass??>
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
</#if>
|
||||
import lombok.experimental.Accessors;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!} DO对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if superEntityClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
@Accessors(chain = true)
|
||||
</#if>
|
||||
<#if table.convert>
|
||||
@TableName("${table.name}")
|
||||
</#if>
|
||||
<#--<#if swagger2>
|
||||
@ApiModel(value = "${entity}对象", description = "${table.comment!}")
|
||||
</#if>-->
|
||||
<#if superEntityClass??>
|
||||
public class ${entity}${cfg.doSuffix} extends ${superEntityClass} <#if activeRecord><${entity}${cfg.doSuffix}></#if> {
|
||||
<#elseif activeRecord>
|
||||
public class ${entity}${cfg.doSuffix} extends Model<${entity}${cfg.doSuffix}> {
|
||||
<#else>
|
||||
public class ${entity}${cfg.doSuffix} implements Serializable {
|
||||
</#if>
|
||||
<#if entitySerialVersionUID>
|
||||
private static final long serialVersionUID = 1L;
|
||||
</#if>
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#-- <#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>-->
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
<#-- </#if>-->
|
||||
</#if>
|
||||
<#if field.keyFlag>
|
||||
<#-- 主键 -->
|
||||
<#if field.keyIdentityFlag>
|
||||
@TableId(value = "${field.name}", type = IdType.AUTO)
|
||||
<#elseif idType??>
|
||||
@TableId(value = "${field.name}", type = IdType.${idType})
|
||||
<#elseif field.convert>
|
||||
@TableId("${field.name}")
|
||||
</#if>
|
||||
<#-- 普通字段 -->
|
||||
<#elseif field.fill??>
|
||||
<#-- ----- 存在字段填充设置 ----->
|
||||
<#if field.convert>
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
<#else>
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
</#if>
|
||||
<#elseif field.convert>
|
||||
@TableField("${field.name}")
|
||||
</#if>
|
||||
<#-- 乐观锁注解 -->
|
||||
<#if (versionFieldName!"") == field.name>
|
||||
@Version
|
||||
</#if>
|
||||
<#-- 逻辑删除注解 -->
|
||||
<#if (logicDeleteFieldName!"") == field.name>
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#if entityColumnConstant>
|
||||
|
||||
<#list table.fields as field>
|
||||
public static final String ${field.name?upper_case} = "${field.name}";
|
||||
</#list>
|
||||
</#if>
|
||||
<#if activeRecord>
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
<#if keyPropertyName??>
|
||||
return this.${keyPropertyName};
|
||||
<#else>
|
||||
return null;
|
||||
</#if>
|
||||
}
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package ${cfg.paramPackage};
|
||||
|
||||
<#--<#list table.importPackages as pkg>-->
|
||||
<#--import ${pkg};-->
|
||||
<#--</#list>-->
|
||||
<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
</#if>
|
||||
<#if cfg.superQueryParamsClass??>
|
||||
import ${cfg.superQueryParamsClass};
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if cfg.superQueryParamsClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
</#if>
|
||||
<#if swagger2>
|
||||
@ApiModel(value = "${entity}查询对象", description = "${table.comment!}")
|
||||
</#if>
|
||||
<#if cfg.superQueryParamsClass??>
|
||||
public class ${entity}${cfg.queryParamsSuffix} extends ${cfg.superQueryParamsName} {
|
||||
<#else>
|
||||
public class ${entity}${cfg.queryParamsSuffix} implements Serializable {
|
||||
</#if>
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
<#--逻辑删除字段不生成-->
|
||||
<#if (logicDeleteFieldName!"") != field.name>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
</#if>
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#if>
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package ${cfg.paramPackage};
|
||||
|
||||
<#--<#list table.importPackages as pkg>-->
|
||||
<#--import ${pkg};-->
|
||||
<#--</#list>-->
|
||||
<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if cfg.superOpsParamsClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
</#if>
|
||||
<#if swagger2>
|
||||
@ApiModel(value = "${entity}更新对象", description = "${table.comment!}")
|
||||
</#if>
|
||||
public class ${entity}${cfg.updateParamsSuffix} implements Serializable {
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
<#--逻辑删除字段不生成-->
|
||||
<#if (logicDeleteFieldName!"") != field.name>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
</#if>
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#if>
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package ${cfg.paramPackage};
|
||||
|
||||
<#list table.importPackages as pkg>
|
||||
import ${pkg};
|
||||
</#list>
|
||||
<#if swagger2>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
</#if>
|
||||
<#if entityLombokModel>
|
||||
import lombok.Data;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${table.comment!} VO对象
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
<#if entityLombokModel>
|
||||
@Data
|
||||
<#if cfg.superOpsParamsClass??>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
</#if>
|
||||
</#if>
|
||||
<#if swagger2>
|
||||
@ApiModel(value = "${entity} VO对象", description = "${table.comment!}")
|
||||
</#if>
|
||||
public class ${entity}${cfg.voSuffix} implements Serializable {
|
||||
<#-- ---------- BEGIN 字段循环遍历 ---------->
|
||||
<#list table.fields as field>
|
||||
|
||||
<#if field.keyFlag>
|
||||
<#assign keyPropertyName="${field.propertyName}"/>
|
||||
</#if>
|
||||
<#if field.comment!?length gt 0>
|
||||
<#if swagger2>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<#else>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
</#if>
|
||||
</#if>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
</#list>
|
||||
<#------------ END 字段循环遍历 ---------->
|
||||
<#if !entityLombokModel>
|
||||
|
||||
<#list table.fields as field>
|
||||
<#if field.propertyType == "boolean">
|
||||
<#assign getprefix="is"/>
|
||||
<#else>
|
||||
<#assign getprefix="get"/>
|
||||
</#if>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<#if entityBuilderModel>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<#else>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
</#if>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<#if entityBuilderModel>
|
||||
return this;
|
||||
</#if>
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#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} +
|
||||
</#if>
|
||||
</#list>
|
||||
"}";
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import ${package.Entity}.${entity}${cfg.doSuffix};
|
||||
import ${superMapperClassPackage};
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}${cfg.doSuffix}> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||
<#if enableCache>
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
</#if>
|
||||
|
||||
<#if baseResultMap>
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}${cfg.doSuffix}">
|
||||
<#list table.fields as field>
|
||||
<#--生成主键排在第一位-->
|
||||
<#if field.keyFlag>
|
||||
<id column="${field.name}" property="${field.propertyName}"/>
|
||||
</#if>
|
||||
</#list>
|
||||
<#--生成公共字段 -->
|
||||
<#list table.commonFields as field>
|
||||
<result column="${field.name}" property="${field.propertyName}"/>
|
||||
</#list>
|
||||
<#--生成普通字段 -->
|
||||
<#list table.fields as field>
|
||||
<#if !field.keyFlag>
|
||||
<result column="${field.name}" property="${field.propertyName}"/>
|
||||
</#if>
|
||||
</#list>
|
||||
</resultMap>
|
||||
</#if>
|
||||
|
||||
<#if baseColumnList>
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="BaseColumnList">
|
||||
<#list table.commonFields as field>
|
||||
${field.name},
|
||||
</#list>
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
</#if>
|
||||
</mapper>
|
||||
@@ -0,0 +1,42 @@
|
||||
package ${package.Service};
|
||||
|
||||
import ${superServiceClassPackage};
|
||||
import ${package.Entity}.${entity}${cfg.doSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.voSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.queryParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.addParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.updateParamsSuffix};
|
||||
import com.afe.ai.common.core.web.page.PageDataInfo;
|
||||
|
||||
/**
|
||||
* ${table.comment!}业务层
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}${cfg.doSuffix}> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param params 新增对象
|
||||
* @return 添加结果
|
||||
*/
|
||||
int save${entity}(${entity}${cfg.addParamsSuffix} params);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param params 修改对象
|
||||
* @return 修改结果
|
||||
*/
|
||||
int update${entity}(${entity}${cfg.updateParamsSuffix} params);
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*
|
||||
* @param params 查询对象
|
||||
* @return 分页对象
|
||||
*/
|
||||
PageDataInfo<${entity}${cfg.voSuffix}> list${entity}Page(${entity}${cfg.queryParamsSuffix} params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.msph.cls.base.model.pojo.PageDataInfo;
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${package.Entity}.${entity}${cfg.doSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.queryParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.addParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.updateParamsSuffix};
|
||||
import ${cfg.paramPackage}.${entity}${cfg.voSuffix};
|
||||
import ${superServiceImplClassPackage};
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* ${table.comment!}业务层
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
* <p>
|
||||
* <p>
|
||||
* Wrapper条件请使用lambda表达式拼接,避免字段修改影响到使用,如:
|
||||
* new UpdateWrapper<${entity}>()
|
||||
* .lambda()
|
||||
* .set(params.getUpdatetime() != null, ${entity}::getUpdatetime, params.getUpdatetime())
|
||||
* .eq(params.getSeqNo() != null, ${entity}::getSeqNo, params.getSeqNo());
|
||||
* 不推荐直接使用字符串,当字段修改时无法感知,如:
|
||||
* new QueryWrapper<${entity}>().eq("seq_no", params.getSeqNo());
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}${cfg.doSuffix}> implements ${table.serviceName} {
|
||||
|
||||
<#assign mapperInstanceName="${table.entityPath}Mapper" />
|
||||
|
||||
@Override
|
||||
public int save${entity}(${entity}${cfg.addParamsSuffix} params) {
|
||||
${entity}${cfg.doSuffix} entity = new ${entity}${cfg.doSuffix}();
|
||||
BeanUtils.copyProperties(params, entity);
|
||||
entity.setCreateTime(new Date());
|
||||
return getBaseMapper().insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update${entity}(${entity}${cfg.updateParamsSuffix} params) {
|
||||
${entity}${cfg.doSuffix} entity = new ${entity}${cfg.doSuffix}();
|
||||
BeanUtils.copyProperties(params, entity);
|
||||
entity.setUpdateTime(new Date());
|
||||
return getBaseMapper().updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDataInfo<${entity}${cfg.voSuffix}> list${entity}Page(${entity}${cfg.queryParamsSuffix} params) {
|
||||
${entity}${cfg.doSuffix} entity = new ${entity}${cfg.doSuffix}();
|
||||
BeanUtils.copyProperties(params, entity);
|
||||
PageHelper.startPage(params.getPageNum(), params.getPageSize());
|
||||
List<${entity}${cfg.doSuffix}> data = getBaseMapper().selectList(new QueryWrapper<>(entity));
|
||||
|
||||
List<${entity}${cfg.voSuffix}> dataVoList = new ArrayList<>();
|
||||
data.forEach(entityDO -> {
|
||||
${entity}${cfg.voSuffix} vo = new ${entity}${cfg.voSuffix}();
|
||||
BeanUtils.copyProperties(entityDO, vo);
|
||||
dataVoList.add(vo);
|
||||
});
|
||||
return new PageDataInfo<>(PageInfo.of(data).getTotal(), dataVoList);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user