master
周文涛 2 years ago
parent 8f551c2f2c
commit fb82959b79

@ -67,7 +67,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<build>

@ -1,6 +1,7 @@
package org.yangliu.codegenerate;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.CaseFormat;
import freemarker.cache.ClassTemplateLoader;
import freemarker.core.XMLOutputFormat;
@ -68,6 +69,19 @@ public class Main {
String user = "enjoy";
String password = "Nomi1234";
//2.选择表配置
String json="{\"oqc_spot_check_record\":\"抽检记录\",\"oqc_shipment_record\":\"成品出货记录\",\"oqc_1008_record\":\"1008仓台账\",\"oqc_after_sales_record\":\"售后记录\",\"oqc_special_sample\":\"特殊样件\",\"oqc_product_record\":\"产品追溯\",\"oqc_ncr_record\":\"NCR明细\",\"oqc_qrqc_record\":\"QRQC明细\"}";
JSONObject tables = JSONObject.parseObject(json);
for (String table : tables.keySet()) {
String entityName = TableFieldUtil.tableNameToEntityName(table);
String description = tables.getString(table);
System.out.println(String.format("表名:%s,实体类:%s,备注:%s",table,entityName,description));
String primaryKeyField = "id";//主键
List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, table);
//3.生成
generate(bussi_package, table,primaryKeyField,entityName,description, tableEntityVoList);
}
/*if(!true){
String table= "oqc_nspection_level_cl";
String entityName="OqcNspectionLevelCl";//实体类
String description = "检验水平-样本代字";//备注
@ -75,6 +89,8 @@ public class Main {
List<TableEntityVo> tableEntityVoList = printTableStructure(driver, url, user, password, table);
//3.生成
generate(bussi_package, table,primaryKeyField,entityName,description, tableEntityVoList);
}*/
}
/**

@ -1,5 +1,6 @@
package org.yangliu.codegenerate.util;
import com.google.common.base.CaseFormat;
import org.yangliu.codegenerate.util.fieldType.DbColumnType;
import org.yangliu.codegenerate.util.fieldType.MySqlTypeConvert;
import org.yangliu.codegenerate.util.fieldType.PostgreSqlTypeConvert;
@ -34,4 +35,11 @@ public class TableFieldUtil {
System.out.println("暂不支持该数据库");
return null;
}
public static String tableNameToEntityName(String tableName){
String to = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tableName);
String orderColumn = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,to);
return orderColumn;
}
}

@ -136,4 +136,11 @@ public class ${entityName}Controller extends BaseController {
public AjaxResult import${entityName}(@RequestPart("file") MultipartFile file) throws Exception {
return ${entityName?uncap_first}Service.import${entityName}(file);
}
/**
* 导入模板
*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException {
${entityName?uncap_first}Service.importTemplateExcel(response);
}
}

@ -63,4 +63,9 @@ public interface I${entityName}Service extends IService<${entityName}> {
* 导入
*/
AjaxResult import${entityName}(MultipartFile file);
/**
* 下载模板
*/
void importTemplateExcel(HttpServletResponse response);
}

@ -194,4 +194,13 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
}
return AjaxResult.success("导入成功");
}
/**
* 下载模板
*/
@Override
public void importTemplateExcel(HttpServletResponse response){
ExcelUtil<${entityName}Excel> util = new ExcelUtil<${entityName}Excel>(${entityName}Excel.class);
util.importTemplateExcel(response, "${tableVo.ftlDescription}");
}
}

@ -0,0 +1,10 @@
{
"oqc_spot_check_record":"抽检记录",
"oqc_shipment_record":"成品出货记录",
"oqc_1008_record":"1008仓台账",
"oqc_after_sales_record":"售后记录",
"oqc_special_sample":"特殊样件",
"oqc_product_record":"产品追溯",
"oqc_ncr_record":"NCR明细",
"oqc_qrqc_record":"QRQC明细"
}
Loading…
Cancel
Save