master
周文涛 2 years ago
parent f59325c5ae
commit 5eec612262

@ -13,10 +13,7 @@ import org.yangliu.codegenerate.entity.TableVo;
import org.yangliu.codegenerate.util.MarkerGenerate; import org.yangliu.codegenerate.util.MarkerGenerate;
import org.yangliu.codegenerate.util.TableFieldUtil; import org.yangliu.codegenerate.util.TableFieldUtil;
import java.io.File; import java.io.*;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -40,6 +37,8 @@ public class Main {
private static String bussi_entity_template = "XXXEntity.javai"; private static String bussi_entity_template = "XXXEntity.javai";
private static String bussi_entity_dto_template = "XXXEntityDTO.javai"; private static String bussi_entity_dto_template = "XXXEntityDTO.javai";
private static String bussi_entity_vo_template = "XXXEntityVO.javai"; private static String bussi_entity_vo_template = "XXXEntityVO.javai";
private static String bussi_entity_add_vo_template = "XXXEntityAddPVO.javai";
private static String bussi_entity_edit_vo_template = "XXXEntityEditPVO.javai";
//mapper模板 //mapper模板
private static String bussi_mapper_template = "XXXMapper.javai"; private static String bussi_mapper_template = "XXXMapper.javai";
@ -111,6 +110,10 @@ public class Main {
String voParsePath = parsePath + "vo" + File.separator; String voParsePath = parsePath + "vo" + File.separator;
MarkerGenerate.generate(templatepath, bussi_entity_vo_template, voParsePath, entityName + "VO.java", dataMap); MarkerGenerate.generate(templatepath, bussi_entity_vo_template, voParsePath, entityName + "VO.java", dataMap);
MarkerGenerate.generate(templatepath, bussi_entity_add_vo_template, voParsePath, "Add"+entityName + "PVO.java", dataMap);
MarkerGenerate.generate(templatepath, bussi_entity_edit_vo_template, voParsePath, "Edit"+entityName + "PVO.java", dataMap);
//生成Mapper //生成Mapper
String mapperParsePath = parsePath + "mapper" + File.separator; String mapperParsePath = parsePath + "mapper" + File.separator;
MarkerGenerate.generate(templatepath, bussi_mapper_template, mapperParsePath, entityName + "Mapper.java", dataMap); MarkerGenerate.generate(templatepath, bussi_mapper_template, mapperParsePath, entityName + "Mapper.java", dataMap);

@ -8,6 +8,8 @@ import com.enjoy.common.log.enums.BusinessType;
import ${bussiPackage}.${entityPackage}.${entityName}; import ${bussiPackage}.${entityPackage}.${entityName};
import ${bussiPackage}.dto.${entityName}DTO; import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.${entityName}VO; import ${bussiPackage}.vo.${entityName}VO;
import ${bussiPackage}.vo.Add${entityName}PVO;
import ${bussiPackage}.vo.Edit${entityName}PVO;
import ${bussiPackage}.service.I${entityName}Service; import ${bussiPackage}.service.I${entityName}Service;
@ -91,7 +93,7 @@ public class ${entityName}Controller extends BaseController {
@ApiOperation(value="新增", notes="新增") @ApiOperation(value="新增", notes="新增")
@Log(title = "新增", businessType = BusinessType.INSERT) @Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ${entityName} ${entityName?uncap_first}) { public AjaxResult add(@RequestBody Add${entityName}PVO ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first}); ${entityName?uncap_first}Service.save(${entityName?uncap_first});
return AjaxResult.success("新增成功"); return AjaxResult.success("新增成功");
} }
@ -104,7 +106,7 @@ public class ${entityName}Controller extends BaseController {
@Log(title = "编辑", businessType = BusinessType.UPDATE) @Log(title = "编辑", businessType = BusinessType.UPDATE)
@ApiOperation(value="编辑", notes="编辑") @ApiOperation(value="编辑", notes="编辑")
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ${entityName} ${entityName?uncap_first}) { public AjaxResult edit(@RequestBody Edit${entityName}PVO ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first}); ${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return AjaxResult.success("编辑成功!"); return AjaxResult.success("编辑成功!");
} }

@ -0,0 +1,49 @@
package ${bussiPackage}.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 新增${tableVo.ftlDescription}对象
* @Author: ${author}
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="新增${tableName}对象", description="${tableVo.ftlDescription}")
public class Add${entityName}PVO implements Serializable{
private static final long serialVersionUID = 1L;
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldType =='Date'>
<#if po.fieldDbType =='date'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#elseif po.fieldDbType =='datetime'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
<#elseif po.fieldDbType =='timestamp'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
<#if po.fieldName == 'delFlag'>
</#if>
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
}

@ -0,0 +1,48 @@
package ${bussiPackage}.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 编辑${tableVo.ftlDescription}对象
* @Author: ${author}
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="编辑${tableName}对象", description="${tableVo.ftlDescription}")
public class Edit${entityName}PVO implements Serializable{
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldType =='Date'>
<#if po.fieldDbType =='date'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#elseif po.fieldDbType =='datetime'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
<#elseif po.fieldDbType =='timestamp'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
<#if po.fieldName == 'delFlag'>
</#if>
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
}
Loading…
Cancel
Save