From bc3db88265ac28353fc053ea6383f8de3f44409f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Thu, 10 Oct 2024 11:52:11 +0800 Subject: [PATCH] 'commit' --- dsUtils/pom.xml | 1 + .../java/com/dsideal/Tools/GenerateCode.java | 49 +++++----- .../java/com/dsideal/ZhuQue/Bean/WxRecord.txt | 92 ------------------- .../dsideal/ZhuQue/Controller/WxRecord.txt | 48 ++++++++++ .../com/dsideal/ZhuQue/Model/WxRecord.txt | 42 +++++++++ .../com/dsideal/ZhuQue/WxRecordController.txt | 48 ++++++++++ .../java/com/dsideal/ZhuQue/WxRecordModel.txt | 42 +++++++++ .../src/main/resources/application.properties | 14 +-- dsUtils/target/classes/application.properties | 14 +-- 9 files changed, 219 insertions(+), 131 deletions(-) delete mode 100644 dsUtils/src/main/java/com/dsideal/ZhuQue/Bean/WxRecord.txt create mode 100644 dsUtils/src/main/java/com/dsideal/ZhuQue/Controller/WxRecord.txt create mode 100644 dsUtils/src/main/java/com/dsideal/ZhuQue/Model/WxRecord.txt create mode 100644 dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordController.txt create mode 100644 dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordModel.txt diff --git a/dsUtils/pom.xml b/dsUtils/pom.xml index 90218f2b..f4996685 100644 --- a/dsUtils/pom.xml +++ b/dsUtils/pom.xml @@ -59,6 +59,7 @@ slf4j-nop 1.7.30 + diff --git a/dsUtils/src/main/java/com/dsideal/Tools/GenerateCode.java b/dsUtils/src/main/java/com/dsideal/Tools/GenerateCode.java index e39cfb90..8cb6c169 100644 --- a/dsUtils/src/main/java/com/dsideal/Tools/GenerateCode.java +++ b/dsUtils/src/main/java/com/dsideal/Tools/GenerateCode.java @@ -1,6 +1,7 @@ package com.dsideal.Tools; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.RuntimeUtil; import cn.hutool.json.JSONObject; import com.dsideal.Utils.dsKit; import com.jfinal.kit.PropKit; @@ -9,7 +10,6 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin; import com.jfinal.plugin.hikaricp.HikariCpPlugin; import javax.sql.DataSource; -import java.io.File; import java.sql.*; import java.util.*; @@ -17,8 +17,6 @@ public class GenerateCode { // JavaBean保存的位置 public static String beanPath; - // JavaBean包名 - public static String beanPackage; // mysql与java的数据类型映射 public static Map dataTypeMap = new HashMap<>(); @@ -101,7 +99,7 @@ public class GenerateCode { jo.put("fields", map); jo.put("beanNameWithoutT", beanNameWithoutT); jo.put("comment", comment); - jo.put("table",table); + jo.put("table", table); return jo; } @@ -136,9 +134,7 @@ public class GenerateCode { public static void main(String[] args) throws Exception { //加载配置文件 PropKit.use("application.properties"); - beanPackage = PropKit.get("beanPackage"); beanPath = PropKit.get("beanPath"); - beanPath = beanPath + "/" + beanPackage.replace(".", "/"); if (!FileUtil.exist(beanPath)) { FileUtil.mkdir(beanPath); } @@ -222,7 +218,7 @@ public class GenerateCode { String table = jo.getStr("table"); StringBuilder sb = new StringBuilder(); - sb.append("-------------------下面是Controller部分-------------------\n"); + //sb.append("//-------------------下面是Controller部分-------------------\n"); //1、增加 sb.append(" //增加" + comment + "\n"); sb.append(" @Before({POST.class})\n"); @@ -281,34 +277,38 @@ public class GenerateCode { sb.append(" }\n"); sb.append("\n"); - sb.append("-------------------下面是Model部分-------------------\n"); + FileUtil.writeUtf8String(sb.toString(), beanPath + "/" + beanNameWithoutT + "Controller.txt"); + + + //sb.append("//-------------------下面是Model部分-------------------\n"); + sb = new StringBuilder(); //1、增加 - sb.append(" //增加"+comment+"\n"); + sb.append(" //增加" + comment + "\n"); sb.append(" public boolean add" + beanNameWithoutT + "(" + fullParameters + "){\n"); sb.append(" Record record = new Record();\n"); for (Map.Entry entry : fields.entrySet()) { - sb.append(" record.set(\"" + entry.getKey() + "\"," +entry.getKey() + ");\n"); + sb.append(" record.set(\"" + entry.getKey() + "\"," + entry.getKey() + ");\n"); } - sb.append(" Db.save(\""+table+"\",\""+key+"\",record);\n"); + sb.append(" Db.save(\"" + table + "\",\"" + key + "\",record);\n"); sb.append("}\n"); //2、删除 sb.append("\n"); - sb.append(" //删除"+comment+"\n"); + sb.append(" //删除" + comment + "\n"); sb.append(" public void del" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n"); - sb.append(" String sql=\"delete from "+table+" where "+key+"=?\";\n"); - sb.append(" Db.update(sql,"+key+");\n"); + sb.append(" String sql=\"delete from " + table + " where " + key + "=?\";\n"); + sb.append(" Db.update(sql," + key + ");\n"); sb.append(" }\n"); sb.append("\n"); //3、修改 - sb.append(" //修改"+comment+"\n"); + sb.append(" //修改" + comment + "\n"); sb.append(" public void update" + beanNameWithoutT + "ById(" + key_type + " " + key + "," + fullParameters + "){\n"); - sb.append(" String sql=\"update "+table+" set "); + sb.append(" String sql=\"update " + table + " set "); for (Map.Entry entry : fields.entrySet()) { sb.append(entry.getKey() + "= ?,"); } sb = sb.deleteCharAt(sb.length() - 1); - sb.append(" where "+key+"=?\";\n"); + sb.append(" where " + key + "=?\";\n"); sb.append(" Db.update(sql,"); for (Map.Entry entry : fields.entrySet()) { sb.append(entry.getKey() + " , "); @@ -318,22 +318,21 @@ public class GenerateCode { sb.append(" }\n"); //4、单条查询 sb.append("\n"); - sb.append(" //单条查询"+comment+"\n"); + sb.append(" //单条查询" + comment + "\n"); sb.append(" public Record get" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n"); - sb.append(" String sql=\"select * from "+table+" where "+key+"=?\";\n"); - sb.append(" return Db.findFirst(sql,"+key+");\n"); + sb.append(" String sql=\"select * from " + table + " where " + key + "=?\";\n"); + sb.append(" return Db.findFirst(sql," + key + ");\n"); sb.append(" }\n"); sb.append("\n"); //5、分页查询 - sb.append(" //分页查询"+comment+"\n"); + sb.append(" //分页查询" + comment + "\n"); sb.append(" public Page get" + beanNameWithoutT + "List(" + key_type + " " + key + ",int pageNum, int pageSize){\n"); - sb.append(" String sql=\"select * from "+table+" where "+key+"=?\";\n"); - sb.append(" return Db.paginate(pageNum, pageSize, sql,"+key+");\n"); + sb.append(" String sql=\"select * from " + table + " where " + key + "=?\";\n"); + sb.append(" return Db.paginate(pageNum, pageSize, sql," + key + ");\n"); sb.append(" }\n"); sb.append("\n"); + FileUtil.writeUtf8String(sb.toString(), beanPath + "/"+ beanNameWithoutT + "Model.txt"); - System.out.println(sb); - FileUtil.writeUtf8String(sb.toString(), beanPath + "/" + beanNameWithoutT + ".txt"); } } diff --git a/dsUtils/src/main/java/com/dsideal/ZhuQue/Bean/WxRecord.txt b/dsUtils/src/main/java/com/dsideal/ZhuQue/Bean/WxRecord.txt deleted file mode 100644 index b8985599..00000000 --- a/dsUtils/src/main/java/com/dsideal/ZhuQue/Bean/WxRecord.txt +++ /dev/null @@ -1,92 +0,0 @@ --------------------下面是Controller部分------------------- - //增加维修记录表 - @Before({POST.class}) - //@JwtCheckInterface({}) - //@EmptyInterface({""}) - //@IsNumericInterface({}) - public void addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ - wm.addWxRecord(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,) - renderJson(RetKit.renderSuccess("操作成功")); - } - - //按ID删除维修记录表 - @Before({POST.class}) - //@JwtCheckInterface({}) - //@EmptyInterface({""}) - //@IsNumericInterface({"id"}) - public void delWxRecordById(int id){ - wm.delWxRecordById(id); - renderJson(RetKit.renderSuccess("操作成功")); - } - - //按ID修改维修记录表 - @Before({POST.class}) - //@JwtCheckInterface({}) - //@EmptyInterface({""}) - //@IsNumericInterface({"id"}) - public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ - wm.updateWxRecordById(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,); - renderJson(RetKit.renderSuccess("操作成功")); - } - - //按ID查询维修记录表 - @Before({GET.class}) - //@JwtCheckInterface({}) - //@EmptyInterface({""}) - //@IsNumericInterface({"id"}) - public void getWxRecordById(int id){ - renderJson(RetKit.renderSuccess(wm.getWxRecordById(id))); - } - - //分页查询维修记录表 - @Before({GET.class}) - //@JwtCheckInterface({}) - //@EmptyInterface({""}) - public void getWxRecordList(int pageNum, int pageSize){ - Page listPage = wm.getWxRecordList(stage_id, pageNum, pageSize); - renderJson(RetKit.renderSuccess(listPage)); - } - --------------------下面是Model部分------------------- - //增加维修记录表 - public boolean addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ - Record record = new Record(); - record.set("station_id",station_id); - record.set("station_name",station_name); - record.set("equipmentId",equipmentId); - record.set("equipmentName",equipmentName); - record.set("connectorId",connectorId); - record.set("connectorNo",connectorNo); - record.set("wx_openid",wx_openid); - record.set("status_id",status_id); - record.set("create_time",create_time); - record.set("type_id",type_id); - record.set("type_name",type_name); - record.set("memo",memo); - Db.save("t_wx_record","id",record); -} - - //删除维修记录表 - public void delWxRecordById(int id){ - String sql="delete from t_wx_record where id=?"; - Db.update(sql,id); - } - - //修改维修记录表 - public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ - String sql="update t_wx_record set station_id= ?,station_name= ?,equipmentId= ?,equipmentName= ?,connectorId= ?,connectorNo= ?,wx_openid= ?,status_id= ?,create_time= ?,type_id= ?,type_name= ?,memo= ? where id=?"; - Db.update(sql,station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , create_time , type_id , type_name , memo , id); - } - - //单条查询维修记录表 - public Record getWxRecordById(int id){ - String sql="select * from t_wx_record where id=?"; - return Db.findFirst(sql,id); - } - - //分页查询维修记录表 - public Page getWxRecordList(int id,int pageNum, int pageSize){ - String sql="select * from t_wx_record where id=?"; - return Db.paginate(pageNum, pageSize, sql,id); - } - diff --git a/dsUtils/src/main/java/com/dsideal/ZhuQue/Controller/WxRecord.txt b/dsUtils/src/main/java/com/dsideal/ZhuQue/Controller/WxRecord.txt new file mode 100644 index 00000000..180c1ed9 --- /dev/null +++ b/dsUtils/src/main/java/com/dsideal/ZhuQue/Controller/WxRecord.txt @@ -0,0 +1,48 @@ + //增加维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({}) + public void addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + wm.addWxRecord(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,) + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID删除维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void delWxRecordById(int id){ + wm.delWxRecordById(id); + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID修改维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + wm.updateWxRecordById(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,); + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID查询维修记录表 + @Before({GET.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void getWxRecordById(int id){ + renderJson(RetKit.renderSuccess(wm.getWxRecordById(id))); + } + + //分页查询维修记录表 + @Before({GET.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + public void getWxRecordList(int pageNum, int pageSize){ + Page listPage = wm.getWxRecordList(stage_id, pageNum, pageSize); + renderJson(RetKit.renderSuccess(listPage)); + } + diff --git a/dsUtils/src/main/java/com/dsideal/ZhuQue/Model/WxRecord.txt b/dsUtils/src/main/java/com/dsideal/ZhuQue/Model/WxRecord.txt new file mode 100644 index 00000000..25a569a3 --- /dev/null +++ b/dsUtils/src/main/java/com/dsideal/ZhuQue/Model/WxRecord.txt @@ -0,0 +1,42 @@ + //增加维修记录表 + public boolean addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + Record record = new Record(); + record.set("station_id",station_id); + record.set("station_name",station_name); + record.set("equipmentId",equipmentId); + record.set("equipmentName",equipmentName); + record.set("connectorId",connectorId); + record.set("connectorNo",connectorNo); + record.set("wx_openid",wx_openid); + record.set("status_id",status_id); + record.set("create_time",create_time); + record.set("type_id",type_id); + record.set("type_name",type_name); + record.set("memo",memo); + Db.save("t_wx_record","id",record); +} + + //删除维修记录表 + public void delWxRecordById(int id){ + String sql="delete from t_wx_record where id=?"; + Db.update(sql,id); + } + + //修改维修记录表 + public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + String sql="update t_wx_record set station_id= ?,station_name= ?,equipmentId= ?,equipmentName= ?,connectorId= ?,connectorNo= ?,wx_openid= ?,status_id= ?,create_time= ?,type_id= ?,type_name= ?,memo= ? where id=?"; + Db.update(sql,station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , create_time , type_id , type_name , memo , id); + } + + //单条查询维修记录表 + public Record getWxRecordById(int id){ + String sql="select * from t_wx_record where id=?"; + return Db.findFirst(sql,id); + } + + //分页查询维修记录表 + public Page getWxRecordList(int id,int pageNum, int pageSize){ + String sql="select * from t_wx_record where id=?"; + return Db.paginate(pageNum, pageSize, sql,id); + } + diff --git a/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordController.txt b/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordController.txt new file mode 100644 index 00000000..180c1ed9 --- /dev/null +++ b/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordController.txt @@ -0,0 +1,48 @@ + //增加维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({}) + public void addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + wm.addWxRecord(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,) + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID删除维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void delWxRecordById(int id){ + wm.delWxRecordById(id); + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID修改维修记录表 + @Before({POST.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + wm.updateWxRecordById(station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , type_id , type_name , memo ,); + renderJson(RetKit.renderSuccess("操作成功")); + } + + //按ID查询维修记录表 + @Before({GET.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + //@IsNumericInterface({"id"}) + public void getWxRecordById(int id){ + renderJson(RetKit.renderSuccess(wm.getWxRecordById(id))); + } + + //分页查询维修记录表 + @Before({GET.class}) + //@JwtCheckInterface({}) + //@EmptyInterface({""}) + public void getWxRecordList(int pageNum, int pageSize){ + Page listPage = wm.getWxRecordList(stage_id, pageNum, pageSize); + renderJson(RetKit.renderSuccess(listPage)); + } + diff --git a/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordModel.txt b/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordModel.txt new file mode 100644 index 00000000..25a569a3 --- /dev/null +++ b/dsUtils/src/main/java/com/dsideal/ZhuQue/WxRecordModel.txt @@ -0,0 +1,42 @@ + //增加维修记录表 + public boolean addWxRecord(int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + Record record = new Record(); + record.set("station_id",station_id); + record.set("station_name",station_name); + record.set("equipmentId",equipmentId); + record.set("equipmentName",equipmentName); + record.set("connectorId",connectorId); + record.set("connectorNo",connectorNo); + record.set("wx_openid",wx_openid); + record.set("status_id",status_id); + record.set("create_time",create_time); + record.set("type_id",type_id); + record.set("type_name",type_name); + record.set("memo",memo); + Db.save("t_wx_record","id",record); +} + + //删除维修记录表 + public void delWxRecordById(int id){ + String sql="delete from t_wx_record where id=?"; + Db.update(sql,id); + } + + //修改维修记录表 + public void updateWxRecordById(int id,int station_id , String station_name , int equipmentId , String equipmentName , int connectorId , String connectorNo , String wx_openid , int status_id , int type_id , String type_name , String memo ,){ + String sql="update t_wx_record set station_id= ?,station_name= ?,equipmentId= ?,equipmentName= ?,connectorId= ?,connectorNo= ?,wx_openid= ?,status_id= ?,create_time= ?,type_id= ?,type_name= ?,memo= ? where id=?"; + Db.update(sql,station_id , station_name , equipmentId , equipmentName , connectorId , connectorNo , wx_openid , status_id , create_time , type_id , type_name , memo , id); + } + + //单条查询维修记录表 + public Record getWxRecordById(int id){ + String sql="select * from t_wx_record where id=?"; + return Db.findFirst(sql,id); + } + + //分页查询维修记录表 + public Page getWxRecordList(int id,int pageNum, int pageSize){ + String sql="select * from t_wx_record where id=?"; + return Db.paginate(pageNum, pageSize, sql,id); + } + diff --git a/dsUtils/src/main/resources/application.properties b/dsUtils/src/main/resources/application.properties index 057cb68e..4d0d3439 100644 --- a/dsUtils/src/main/resources/application.properties +++ b/dsUtils/src/main/resources/application.properties @@ -1,15 +1,15 @@ -# ????? +# 数据库驱动 driverClassName=com.mysql.cj.jdbc.Driver user=root password=DsideaL147258369 jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false -# ???? -beanPath=D:/dsWork/dsProject/dsUtils/src/main/java -# ??bean??? -beanPackage=com.dsideal.ZhuQue.Bean -# ??????? +# 生成的bean存放路径 +beanPath=D:/dsWork/dsProject/dsUtils/src/main/java/com/dsideal/ZhuQue +# 表 tableName=t_wx_record -# dao??? +# dao的名称 daoName=wm +formatJar=D:/dsWork/dsProject/dsUtils/lib/google-java-format-1.24.0-all-deps.jar + diff --git a/dsUtils/target/classes/application.properties b/dsUtils/target/classes/application.properties index 057cb68e..4d0d3439 100644 --- a/dsUtils/target/classes/application.properties +++ b/dsUtils/target/classes/application.properties @@ -1,15 +1,15 @@ -# ????? +# 数据库驱动 driverClassName=com.mysql.cj.jdbc.Driver user=root password=DsideaL147258369 jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false -# ???? -beanPath=D:/dsWork/dsProject/dsUtils/src/main/java -# ??bean??? -beanPackage=com.dsideal.ZhuQue.Bean -# ??????? +# 生成的bean存放路径 +beanPath=D:/dsWork/dsProject/dsUtils/src/main/java/com/dsideal/ZhuQue +# 表 tableName=t_wx_record -# dao??? +# dao的名称 daoName=wm +formatJar=D:/dsWork/dsProject/dsUtils/lib/google-java-format-1.24.0-all-deps.jar +