From ec26095232d14dbc5c94200b9155fee0f767e43a Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Tue, 15 Aug 2023 17:33:47 +0800 Subject: [PATCH] updates --- .../java/org/yangliu/codegenerate/Main.java | 10 +++--- .../codegenerate/entity/TableEntityVo.java | 16 ++++----- src/main/resources/yangliu/XXXEntity.javai | 36 ++++++++----------- .../resources/yangliu/XXXEntityAddPVO.javai | 4 +-- .../resources/yangliu/XXXEntityEditPVO.javai | 4 +-- .../resources/yangliu/XXXEntityExcel.javai | 20 +++++------ .../resources/yangliu/XXXEntityQueryVO.javai | 4 +-- .../resources/yangliu/XXXServiceImpl.javai | 2 ++ 8 files changed, 46 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/yangliu/codegenerate/Main.java b/src/main/java/org/yangliu/codegenerate/Main.java index a7eaa07..8cf7fa9 100644 --- a/src/main/java/org/yangliu/codegenerate/Main.java +++ b/src/main/java/org/yangliu/codegenerate/Main.java @@ -68,9 +68,9 @@ public class Main { String user = "enjoy"; String password = "Nomi1234"; //2.选择表配置 - String table= "oqc_report_template"; - String entityName="OqcReportTemplate";//实体类 - String description = "报告模板";//备注 + String table= "oqc_sampling_plan"; + String entityName="OqcSamplingPlan";//实体类 + String description = "抽样方案";//备注 String primaryKeyField = "id";//主键 List tableEntityVoList = printTableStructure(driver, url, user, password, table); //3.生成 @@ -182,8 +182,10 @@ public class Main { int nullable = columnResultSet.getInt("NULLABLE"); // 描述 String remarks = columnResultSet.getString("REMARKS"); + if (remarks==null) { + 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); tableEntityVoList.add(new TableEntityVo(columnName,entityField,TableFieldUtil.fieldTypeParseJava(dbType, columnType), columnType, remarks)); } diff --git a/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java b/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java index ae6b16b..53119c6 100644 --- a/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java +++ b/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java @@ -15,18 +15,18 @@ public class TableEntityVo { //数据库中字段类型 private String fieldDbType; //字段描述 - private String filedComment; + private String fieldComment; 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.fieldName = fieldName; this.fieldType = fieldType; this.fieldDbType = fieldDbType; - this.filedComment = filedComment; + this.fieldComment = fieldComment; } public String getFieldColumn() { @@ -37,12 +37,12 @@ public class TableEntityVo { this.fieldColumn = fieldColumn; } - public String getFiledComment() { - return filedComment; + public String getFieldComment() { + return fieldComment; } - public void setFiledComment(String filedComment) { - this.filedComment = filedComment; + public void setFieldComment(String fieldComment) { + this.fieldComment = fieldComment; } public String getFieldName() { @@ -75,7 +75,7 @@ public class TableEntityVo { "fieldName='" + fieldName + '\'' + ", fieldType='" + fieldType + '\'' + ", fieldDbType='" + fieldDbType + '\'' + - ", filedComment='" + filedComment + '\'' + + ", fieldComment='" + fieldComment + '\'' + '}'; } } diff --git a/src/main/resources/yangliu/XXXEntity.javai b/src/main/resources/yangliu/XXXEntity.javai index b72ae8d..d9b4f56 100644 --- a/src/main/resources/yangliu/XXXEntity.javai +++ b/src/main/resources/yangliu/XXXEntity.javai @@ -1,9 +1,6 @@ package ${bussiPackage}.${entityPackage}; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.*; import com.enjoy.common.core.annotation.Excel; import com.enjoy.common.core.utils.iqc.ExcelImport; import com.enjoy.oqc.domain.BaseEntity; @@ -32,38 +29,33 @@ public class ${entityName} extends BaseEntity{ private static final long serialVersionUID = 1L; <#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> - /**${po.filedComment}*/ <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> <#if po.fieldType =='Date'> <#if po.fieldDbType =='date'> - @Excel(name = "${po.filedComment}", width = 15) - @ExcelImport("${po.filedComment}") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd") - <#elseif po.fieldDbType =='datetime'> - @Excel(name = "${po.filedComment}", width = 20) - @ExcelImport("${po.filedComment}") + <#elseif po.fieldDbType =='datetime' || po.fieldDbType = 'timestamp'> @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") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - - <#else> - @Excel(name = "${po.filedComment}", width = 15) - @ExcelImport("${po.filedComment}") - + + <#else> + - @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}") + + @TableField(value="${po.fieldColumn}") <#if po.fieldName == 'delFlag'> @TableLogic private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType} ${po.fieldName}; - + } diff --git a/src/main/resources/yangliu/XXXEntityAddPVO.javai b/src/main/resources/yangliu/XXXEntityAddPVO.javai index 3902477..0470279 100644 --- a/src/main/resources/yangliu/XXXEntityAddPVO.javai +++ b/src/main/resources/yangliu/XXXEntityAddPVO.javai @@ -26,7 +26,7 @@ public class Add${entityName}PVO implements Serializable{ <#list originalColumns as po> <#if po.fieldName == primaryKeyField> <#else> - /**${po.filedComment}*/ + /**${po.fieldComment}*/ <#if po.fieldType =='Date'> <#if po.fieldDbType =='date'> @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @@ -42,7 +42,7 @@ public class Add${entityName}PVO implements Serializable{ <#if po.fieldName != primaryKeyField> - @ApiModelProperty(value = "${po.filedComment}") + @ApiModelProperty(value = "${po.fieldComment}") private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType} ${po.fieldName}; diff --git a/src/main/resources/yangliu/XXXEntityEditPVO.javai b/src/main/resources/yangliu/XXXEntityEditPVO.javai index dd7c8b6..567ef95 100644 --- a/src/main/resources/yangliu/XXXEntityEditPVO.javai +++ b/src/main/resources/yangliu/XXXEntityEditPVO.javai @@ -23,7 +23,7 @@ import java.util.Date; @ApiModel(value="编辑${tableName}对象", description="${tableVo.ftlDescription}") public class Edit${entityName}PVO implements Serializable{ <#list originalColumns as po> - /**${po.filedComment}*/ + /**${po.fieldComment}*/ <#if po.fieldName == primaryKeyField> <#else> <#if po.fieldType =='Date'> @@ -40,7 +40,7 @@ public class Edit${entityName}PVO implements Serializable{ <#else> - @ApiModelProperty(value = "${po.filedComment}") + @ApiModelProperty(value = "${po.fieldComment}") <#if po.fieldName == 'delFlag'> private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType} ${po.fieldName}; diff --git a/src/main/resources/yangliu/XXXEntityExcel.javai b/src/main/resources/yangliu/XXXEntityExcel.javai index 1cea1c9..370f0f3 100644 --- a/src/main/resources/yangliu/XXXEntityExcel.javai +++ b/src/main/resources/yangliu/XXXEntityExcel.javai @@ -25,33 +25,33 @@ public class ${entityName}Excel{ private static final long serialVersionUID = 1L; <#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> - /**${po.filedComment}*/ + /**${po.fieldComment}*/ <#if po.fieldName == primaryKeyField> @TableId(type = IdType.ASSIGN_ID) <#else> <#if po.fieldType =='Date'> <#if po.fieldDbType =='date'> - @Excel(name = "${po.filedComment}", width = 15) - @ExcelImport("${po.filedComment}") + @Excel(name = "${po.fieldComment}", width = 15) + @ExcelImport("${po.fieldComment}") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd") <#elseif po.fieldDbType =='datetime'> - @Excel(name = "${po.filedComment}", width = 20) - @ExcelImport("${po.filedComment}") + @Excel(name = "${po.fieldComment}", width = 20) + @ExcelImport("${po.fieldComment}") @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}") + @Excel(name = "${po.fieldComment}", width = 20) + @ExcelImport("${po.fieldComment}") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") <#else> - @Excel(name = "${po.filedComment}", width = 15) - @ExcelImport("${po.filedComment}") + @Excel(name = "${po.fieldComment}", width = 15) + @ExcelImport("${po.fieldComment}") - @ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}") + @ApiModelProperty(value = "${po.fieldComment}",example = "${po.fieldComment}") <#if po.fieldName == 'delFlag'> @TableLogic diff --git a/src/main/resources/yangliu/XXXEntityQueryVO.javai b/src/main/resources/yangliu/XXXEntityQueryVO.javai index 741f85b..48c44dd 100644 --- a/src/main/resources/yangliu/XXXEntityQueryVO.javai +++ b/src/main/resources/yangliu/XXXEntityQueryVO.javai @@ -23,7 +23,7 @@ import java.util.Date; @ApiModel(value="查询${entityName}对象", description="${tableVo.ftlDescription}") public class Query${entityName}VO implements Serializable{ <#list originalColumns as po> - /**${po.filedComment}*/ + /**${po.fieldComment}*/ <#if po.fieldName == primaryKeyField> <#else> <#if po.fieldType =='Date'> @@ -40,7 +40,7 @@ public class Query${entityName}VO implements Serializable{ <#else> - @ApiModelProperty(value = "${po.filedComment}") + @ApiModelProperty(value = "${po.fieldComment}") <#if po.fieldName == 'delFlag'> private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType} ${po.fieldName}; diff --git a/src/main/resources/yangliu/XXXServiceImpl.javai b/src/main/resources/yangliu/XXXServiceImpl.javai index be99236..bf4b0db 100644 --- a/src/main/resources/yangliu/XXXServiceImpl.javai +++ b/src/main/resources/yangliu/XXXServiceImpl.javai @@ -83,6 +83,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ /** * 全部 */ + @Override public AjaxResult listAll(Query${entityName}VO query${entityName}VO){ List<${entityName}DTO> list=new ArrayList(); 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){ ${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO(); ${uncap_first}DTO =(${entityName}DTO) BeanHkUtils.copyProperties(this.getById(id),${uncap_first}DTO);