master
周文涛 2 years ago
parent 643d516be0
commit ec26095232

@ -68,9 +68,9 @@ public class Main {
String user = "enjoy"; String user = "enjoy";
String password = "Nomi1234"; String password = "Nomi1234";
//2.选择表配置 //2.选择表配置
String table= "oqc_report_template"; String table= "oqc_sampling_plan";
String entityName="OqcReportTemplate";//实体类 String entityName="OqcSamplingPlan";//实体类
String description = "报告模板";//备注 String description = "抽样方案";//备注
String primaryKeyField = "id";//主键 String primaryKeyField = "id";//主键
List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, table); List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, table);
//3.生成 //3.生成
@ -182,8 +182,10 @@ public class Main {
int nullable = columnResultSet.getInt("NULLABLE"); int nullable = columnResultSet.getInt("NULLABLE");
// 描述 // 描述
String remarks = columnResultSet.getString("REMARKS"); String remarks = columnResultSet.getString("REMARKS");
if (remarks==null) {
remarks="";
}
System.out.println(columnName + " " + columnType + " " + datasize + " " + digits + " " + nullable + " " + remarks); System.out.println(columnName + " " + columnType + " " + datasize + " " + digits + " " + nullable + " " + remarks);
//System.out.println("1"+TableFieldUtil.fieldTypeParseJava(dbType,columnType));
String entityField = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName); String entityField = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName);
tableEntityVoList.add(new TableEntityVo(columnName,entityField,TableFieldUtil.fieldTypeParseJava(dbType, columnType), columnType, remarks)); tableEntityVoList.add(new TableEntityVo(columnName,entityField,TableFieldUtil.fieldTypeParseJava(dbType, columnType), columnType, remarks));
} }

@ -15,18 +15,18 @@ public class TableEntityVo {
//数据库中字段类型 //数据库中字段类型
private String fieldDbType; private String fieldDbType;
//字段描述 //字段描述
private String filedComment; private String fieldComment;
public TableEntityVo() { public TableEntityVo() {
} }
public TableEntityVo(String fieldColumn,String fieldName,String fieldType,String fieldDbType,String filedComment) { public TableEntityVo(String fieldColumn,String fieldName,String fieldType,String fieldDbType,String fieldComment) {
this.fieldColumn = fieldColumn; this.fieldColumn = fieldColumn;
this.fieldName = fieldName; this.fieldName = fieldName;
this.fieldType = fieldType; this.fieldType = fieldType;
this.fieldDbType = fieldDbType; this.fieldDbType = fieldDbType;
this.filedComment = filedComment; this.fieldComment = fieldComment;
} }
public String getFieldColumn() { public String getFieldColumn() {
@ -37,12 +37,12 @@ public class TableEntityVo {
this.fieldColumn = fieldColumn; this.fieldColumn = fieldColumn;
} }
public String getFiledComment() { public String getFieldComment() {
return filedComment; return fieldComment;
} }
public void setFiledComment(String filedComment) { public void setFieldComment(String fieldComment) {
this.filedComment = filedComment; this.fieldComment = fieldComment;
} }
public String getFieldName() { public String getFieldName() {
@ -75,7 +75,7 @@ public class TableEntityVo {
"fieldName='" + fieldName + '\'' + "fieldName='" + fieldName + '\'' +
", fieldType='" + fieldType + '\'' + ", fieldType='" + fieldType + '\'' +
", fieldDbType='" + fieldDbType + '\'' + ", fieldDbType='" + fieldDbType + '\'' +
", filedComment='" + filedComment + '\'' + ", fieldComment='" + fieldComment + '\'' +
'}'; '}';
} }
} }

@ -1,9 +1,6 @@
package ${bussiPackage}.${entityPackage}; package ${bussiPackage}.${entityPackage};
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.enjoy.common.core.annotation.Excel; import com.enjoy.common.core.annotation.Excel;
import com.enjoy.common.core.utils.iqc.ExcelImport; import com.enjoy.common.core.utils.iqc.ExcelImport;
import com.enjoy.oqc.domain.BaseEntity; import com.enjoy.oqc.domain.BaseEntity;
@ -32,33 +29,28 @@ public class ${entityName} extends BaseEntity{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
<#list originalColumns as po> <#list originalColumns as po>
<#if po.fieldName == 'creatorId' || po.fieldName == 'createBy' || po.fieldName == 'createTime' || po.fieldName == 'updaterId' || po.fieldName == 'updateBy' || po.fieldName == 'updateTime' || po.fieldName == 'tenantId'><#else> <#if po.fieldName == 'creatorId' || po.fieldName == 'createBy' || po.fieldName == 'createTime' || po.fieldName == 'updaterId' || po.fieldName == 'updateBy' || po.fieldName == 'updateTime' || po.fieldName == 'tenantId'><#else>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField> <#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
<#else> <#else>
<#if po.fieldType =='Date'> <#if po.fieldType =='Date'>
<#if po.fieldDbType =='date'> <#if po.fieldDbType =='date'>
@Excel(name = "${po.filedComment}", width = 15)
@ExcelImport("${po.filedComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd")
<#elseif po.fieldDbType =='datetime'> <#elseif po.fieldDbType =='datetime' || po.fieldDbType = 'timestamp'>
@Excel(name = "${po.filedComment}", width = 20)
@ExcelImport("${po.filedComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
<#elseif po.fieldDbType =='timestamp'>
@Excel(name = "${po.filedComment}", width = 20)
@ExcelImport("${po.filedComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if> </#if>
<#else> <#else>
@Excel(name = "${po.filedComment}", width = 15)
@ExcelImport("${po.filedComment}")
</#if> </#if>
</#if> </#if>
@ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}")
<#if po.fieldComment !=''>
/**${po.fieldComment}*/
@Excel(name = "${po.fieldComment}", width = 15)
@ExcelImport("${po.fieldComment}")
@ApiModelProperty(value = "${po.fieldComment}")
</#if>
@TableField(value="${po.fieldColumn}")
<#if po.fieldName == 'delFlag'> <#if po.fieldName == 'delFlag'>
@TableLogic @TableLogic
</#if> </#if>

@ -26,7 +26,7 @@ public class Add${entityName}PVO implements Serializable{
<#list originalColumns as po> <#list originalColumns as po>
<#if po.fieldName == primaryKeyField> <#if po.fieldName == primaryKeyField>
<#else> <#else>
/**${po.filedComment}*/ /**${po.fieldComment}*/
<#if po.fieldType =='Date'> <#if po.fieldType =='Date'>
<#if po.fieldDbType =='date'> <#if po.fieldDbType =='date'>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@ -42,7 +42,7 @@ public class Add${entityName}PVO implements Serializable{
</#if> </#if>
</#if> </#if>
<#if po.fieldName != primaryKeyField> <#if po.fieldName != primaryKeyField>
@ApiModelProperty(value = "${po.filedComment}") @ApiModelProperty(value = "${po.fieldComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName}; private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#if> </#if>
</#list> </#list>

@ -23,7 +23,7 @@ import java.util.Date;
@ApiModel(value="编辑${tableName}对象", description="${tableVo.ftlDescription}") @ApiModel(value="编辑${tableName}对象", description="${tableVo.ftlDescription}")
public class Edit${entityName}PVO implements Serializable{ public class Edit${entityName}PVO implements Serializable{
<#list originalColumns as po> <#list originalColumns as po>
/**${po.filedComment}*/ /**${po.fieldComment}*/
<#if po.fieldName == primaryKeyField> <#if po.fieldName == primaryKeyField>
<#else> <#else>
<#if po.fieldType =='Date'> <#if po.fieldType =='Date'>
@ -40,7 +40,7 @@ public class Edit${entityName}PVO implements Serializable{
<#else> <#else>
</#if> </#if>
</#if> </#if>
@ApiModelProperty(value = "${po.filedComment}") @ApiModelProperty(value = "${po.fieldComment}")
<#if po.fieldName == 'delFlag'> <#if po.fieldName == 'delFlag'>
</#if> </#if>
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName}; private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};

@ -25,33 +25,33 @@ public class ${entityName}Excel{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
<#list originalColumns as po> <#list originalColumns as po>
<#if po.fieldName =='id'|| po.fieldName=='delFlag' || po.fieldName == 'creatorId' || po.fieldName == 'createBy' || po.fieldName == 'createTime' || po.fieldName == 'updaterId' || po.fieldName == 'updateBy' || po.fieldName == 'updateTime' || po.fieldName == 'tenantId'><#else> <#if po.fieldName =='id'|| po.fieldName=='delFlag' || po.fieldName == 'creatorId' || po.fieldName == 'createBy' || po.fieldName == 'createTime' || po.fieldName == 'updaterId' || po.fieldName == 'updateBy' || po.fieldName == 'updateTime' || po.fieldName == 'tenantId'><#else>
/**${po.filedComment}*/ /**${po.fieldComment}*/
<#if po.fieldName == primaryKeyField> <#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
<#else> <#else>
<#if po.fieldType =='Date'> <#if po.fieldType =='Date'>
<#if po.fieldDbType =='date'> <#if po.fieldDbType =='date'>
@Excel(name = "${po.filedComment}", width = 15) @Excel(name = "${po.fieldComment}", width = 15)
@ExcelImport("${po.filedComment}") @ExcelImport("${po.fieldComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd")
<#elseif po.fieldDbType =='datetime'> <#elseif po.fieldDbType =='datetime'>
@Excel(name = "${po.filedComment}", width = 20) @Excel(name = "${po.fieldComment}", width = 20)
@ExcelImport("${po.filedComment}") @ExcelImport("${po.fieldComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
<#elseif po.fieldDbType =='timestamp'> <#elseif po.fieldDbType =='timestamp'>
@Excel(name = "${po.filedComment}", width = 20) @Excel(name = "${po.fieldComment}", width = 20)
@ExcelImport("${po.filedComment}") @ExcelImport("${po.fieldComment}")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if> </#if>
<#else> <#else>
@Excel(name = "${po.filedComment}", width = 15) @Excel(name = "${po.fieldComment}", width = 15)
@ExcelImport("${po.filedComment}") @ExcelImport("${po.fieldComment}")
</#if> </#if>
</#if> </#if>
@ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}") @ApiModelProperty(value = "${po.fieldComment}",example = "${po.fieldComment}")
<#if po.fieldName == 'delFlag'> <#if po.fieldName == 'delFlag'>
@TableLogic @TableLogic
</#if> </#if>

@ -23,7 +23,7 @@ import java.util.Date;
@ApiModel(value="查询${entityName}对象", description="${tableVo.ftlDescription}") @ApiModel(value="查询${entityName}对象", description="${tableVo.ftlDescription}")
public class Query${entityName}VO implements Serializable{ public class Query${entityName}VO implements Serializable{
<#list originalColumns as po> <#list originalColumns as po>
/**${po.filedComment}*/ /**${po.fieldComment}*/
<#if po.fieldName == primaryKeyField> <#if po.fieldName == primaryKeyField>
<#else> <#else>
<#if po.fieldType =='Date'> <#if po.fieldType =='Date'>
@ -40,7 +40,7 @@ public class Query${entityName}VO implements Serializable{
<#else> <#else>
</#if> </#if>
</#if> </#if>
@ApiModelProperty(value = "${po.filedComment}") @ApiModelProperty(value = "${po.fieldComment}")
<#if po.fieldName == 'delFlag'> <#if po.fieldName == 'delFlag'>
</#if> </#if>
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName}; private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};

@ -83,6 +83,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
/** /**
* 全部 * 全部
*/ */
@Override
public AjaxResult listAll(Query${entityName}VO query${entityName}VO){ public AjaxResult listAll(Query${entityName}VO query${entityName}VO){
List<${entityName}DTO> list=new ArrayList(); List<${entityName}DTO> list=new ArrayList();
QueryWrapper<${entityName}> queryWrapper=new QueryWrapper(); QueryWrapper<${entityName}> queryWrapper=new QueryWrapper();
@ -100,6 +101,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
/** /**
* 详情 * 详情
*/ */
@Override
public AjaxResult get${entityName}Detail(String id){ public AjaxResult get${entityName}Detail(String id){
${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO(); ${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO();
${uncap_first}DTO =(${entityName}DTO) BeanHkUtils.copyProperties(this.getById(id),${uncap_first}DTO); ${uncap_first}DTO =(${entityName}DTO) BeanHkUtils.copyProperties(this.getById(id),${uncap_first}DTO);

Loading…
Cancel
Save