main
黄海 10 months ago
parent 58fc2081ad
commit bc3db88265

@ -59,6 +59,7 @@
<artifactId>slf4j-nop</artifactId> <artifactId>slf4j-nop</artifactId>
<version>1.7.30</version> <version>1.7.30</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<!--安装hutool--> <!--安装hutool-->
<dependency> <dependency>

@ -1,6 +1,7 @@
package com.dsideal.Tools; package com.dsideal.Tools;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.RuntimeUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.dsideal.Utils.dsKit; import com.dsideal.Utils.dsKit;
import com.jfinal.kit.PropKit; import com.jfinal.kit.PropKit;
@ -9,7 +10,6 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.hikaricp.HikariCpPlugin; import com.jfinal.plugin.hikaricp.HikariCpPlugin;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.File;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
@ -17,8 +17,6 @@ public class GenerateCode {
// JavaBean保存的位置 // JavaBean保存的位置
public static String beanPath; public static String beanPath;
// JavaBean包名
public static String beanPackage;
// mysql与java的数据类型映射 // mysql与java的数据类型映射
public static Map<String, String> dataTypeMap = new HashMap<>(); public static Map<String, String> dataTypeMap = new HashMap<>();
@ -101,7 +99,7 @@ public class GenerateCode {
jo.put("fields", map); jo.put("fields", map);
jo.put("beanNameWithoutT", beanNameWithoutT); jo.put("beanNameWithoutT", beanNameWithoutT);
jo.put("comment", comment); jo.put("comment", comment);
jo.put("table",table); jo.put("table", table);
return jo; return jo;
} }
@ -136,9 +134,7 @@ public class GenerateCode {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//加载配置文件 //加载配置文件
PropKit.use("application.properties"); PropKit.use("application.properties");
beanPackage = PropKit.get("beanPackage");
beanPath = PropKit.get("beanPath"); beanPath = PropKit.get("beanPath");
beanPath = beanPath + "/" + beanPackage.replace(".", "/");
if (!FileUtil.exist(beanPath)) { if (!FileUtil.exist(beanPath)) {
FileUtil.mkdir(beanPath); FileUtil.mkdir(beanPath);
} }
@ -222,7 +218,7 @@ public class GenerateCode {
String table = jo.getStr("table"); String table = jo.getStr("table");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("-------------------下面是Controller部分-------------------\n"); //sb.append("//-------------------下面是Controller部分-------------------\n");
//1、增加 //1、增加
sb.append(" //增加" + comment + "\n"); sb.append(" //增加" + comment + "\n");
sb.append(" @Before({POST.class})\n"); sb.append(" @Before({POST.class})\n");
@ -281,34 +277,38 @@ public class GenerateCode {
sb.append(" }\n"); sb.append(" }\n");
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、增加 //1、增加
sb.append(" //增加"+comment+"\n"); sb.append(" //增加" + comment + "\n");
sb.append(" public boolean add" + beanNameWithoutT + "(" + fullParameters + "){\n"); sb.append(" public boolean add" + beanNameWithoutT + "(" + fullParameters + "){\n");
sb.append(" Record record = new Record();\n"); sb.append(" Record record = new Record();\n");
for (Map.Entry<String, String> entry : fields.entrySet()) { for (Map.Entry<String, String> 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"); sb.append("}\n");
//2、删除 //2、删除
sb.append("\n"); sb.append("\n");
sb.append(" //删除"+comment+"\n"); sb.append(" //删除" + comment + "\n");
sb.append(" public void del" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n"); sb.append(" public void del" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n");
sb.append(" String sql=\"delete from "+table+" where "+key+"=?\";\n"); sb.append(" String sql=\"delete from " + table + " where " + key + "=?\";\n");
sb.append(" Db.update(sql,"+key+");\n"); sb.append(" Db.update(sql," + key + ");\n");
sb.append(" }\n"); sb.append(" }\n");
sb.append("\n"); sb.append("\n");
//3、修改 //3、修改
sb.append(" //修改"+comment+"\n"); sb.append(" //修改" + comment + "\n");
sb.append(" public void update" + beanNameWithoutT + "ById(" + key_type + " " + key + "," + fullParameters + "){\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<String, String> entry : fields.entrySet()) { for (Map.Entry<String, String> entry : fields.entrySet()) {
sb.append(entry.getKey() + "= ?,"); sb.append(entry.getKey() + "= ?,");
} }
sb = sb.deleteCharAt(sb.length() - 1); sb = sb.deleteCharAt(sb.length() - 1);
sb.append(" where "+key+"=?\";\n"); sb.append(" where " + key + "=?\";\n");
sb.append(" Db.update(sql,"); sb.append(" Db.update(sql,");
for (Map.Entry<String, String> entry : fields.entrySet()) { for (Map.Entry<String, String> entry : fields.entrySet()) {
sb.append(entry.getKey() + " , "); sb.append(entry.getKey() + " , ");
@ -318,22 +318,21 @@ public class GenerateCode {
sb.append(" }\n"); sb.append(" }\n");
//4、单条查询 //4、单条查询
sb.append("\n"); sb.append("\n");
sb.append(" //单条查询"+comment+"\n"); sb.append(" //单条查询" + comment + "\n");
sb.append(" public Record get" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n"); sb.append(" public Record get" + beanNameWithoutT + "ById(" + key_type + " " + key + "){\n");
sb.append(" String sql=\"select * from "+table+" where "+key+"=?\";\n"); sb.append(" String sql=\"select * from " + table + " where " + key + "=?\";\n");
sb.append(" return Db.findFirst(sql,"+key+");\n"); sb.append(" return Db.findFirst(sql," + key + ");\n");
sb.append(" }\n"); sb.append(" }\n");
sb.append("\n"); sb.append("\n");
//5、分页查询 //5、分页查询
sb.append(" //分页查询"+comment+"\n"); sb.append(" //分页查询" + comment + "\n");
sb.append(" public Page<Record> get" + beanNameWithoutT + "List(" + key_type + " " + key + ",int pageNum, int pageSize){\n"); sb.append(" public Page<Record> get" + beanNameWithoutT + "List(" + key_type + " " + key + ",int pageNum, int pageSize){\n");
sb.append(" String sql=\"select * from "+table+" where "+key+"=?\";\n"); sb.append(" String sql=\"select * from " + table + " where " + key + "=?\";\n");
sb.append(" return Db.paginate(pageNum, pageSize, sql,"+key+");\n"); sb.append(" return Db.paginate(pageNum, pageSize, sql," + key + ");\n");
sb.append(" }\n"); sb.append(" }\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");
} }
} }

@ -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<Record> 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<Record> getWxRecordList(int id,int pageNum, int pageSize){
String sql="select * from t_wx_record where id=?";
return Db.paginate(pageNum, pageSize, sql,id);
}

@ -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<Record> listPage = wm.getWxRecordList(stage_id, pageNum, pageSize);
renderJson(RetKit.renderSuccess(listPage));
}

@ -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<Record> getWxRecordList(int id,int pageNum, int pageSize){
String sql="select * from t_wx_record where id=?";
return Db.paginate(pageNum, pageSize, sql,id);
}

@ -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<Record> listPage = wm.getWxRecordList(stage_id, pageNum, pageSize);
renderJson(RetKit.renderSuccess(listPage));
}

@ -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<Record> getWxRecordList(int id,int pageNum, int pageSize){
String sql="select * from t_wx_record where id=?";
return Db.paginate(pageNum, pageSize, sql,id);
}

@ -1,15 +1,15 @@
# ????? # 数据库驱动
driverClassName=com.mysql.cj.jdbc.Driver driverClassName=com.mysql.cj.jdbc.Driver
user=root user=root
password=DsideaL147258369 password=DsideaL147258369
jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false
# ???? # 生成的bean存放路径
beanPath=D:/dsWork/dsProject/dsUtils/src/main/java beanPath=D:/dsWork/dsProject/dsUtils/src/main/java/com/dsideal/ZhuQue
# ??bean??? # 表
beanPackage=com.dsideal.ZhuQue.Bean
# ???????
tableName=t_wx_record tableName=t_wx_record
# dao??? # dao的名称
daoName=wm daoName=wm
formatJar=D:/dsWork/dsProject/dsUtils/lib/google-java-format-1.24.0-all-deps.jar

@ -1,15 +1,15 @@
# ????? # 数据库驱动
driverClassName=com.mysql.cj.jdbc.Driver driverClassName=com.mysql.cj.jdbc.Driver
user=root user=root
password=DsideaL147258369 password=DsideaL147258369
jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false jdbcUrl=jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false
# ???? # 生成的bean存放路径
beanPath=D:/dsWork/dsProject/dsUtils/src/main/java beanPath=D:/dsWork/dsProject/dsUtils/src/main/java/com/dsideal/ZhuQue
# ??bean??? # 表
beanPackage=com.dsideal.ZhuQue.Bean
# ???????
tableName=t_wx_record tableName=t_wx_record
# dao??? # dao的名称
daoName=wm daoName=wm
formatJar=D:/dsWork/dsProject/dsUtils/lib/google-java-format-1.24.0-all-deps.jar

Loading…
Cancel
Save