parent
bd962e6fe6
commit
26a8868108
@ -0,0 +1,31 @@
|
|||||||
|
package com.dsideal.GenerateCode;
|
||||||
|
|
||||||
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||||
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class getJavaBean {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// 配置Druid数据源插件
|
||||||
|
HikariCpPlugin hpPlugin = new HikariCpPlugin(
|
||||||
|
"jdbc:mysql://10.10.14.210:22066/ds_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false",
|
||||||
|
"root",
|
||||||
|
"DsideaL147258369",
|
||||||
|
"com.mysql.cj.jdbc.Driver");
|
||||||
|
|
||||||
|
// 配置ActiveRecord插件
|
||||||
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(hpPlugin);
|
||||||
|
hpPlugin.start();
|
||||||
|
arp.start();
|
||||||
|
|
||||||
|
AutoCreatedEntityName autoCreatedEntityName = new AutoCreatedEntityName();
|
||||||
|
autoCreatedEntityName.created(new String[]{"t_wx_record"},"com.dsideal");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,255 @@
|
|||||||
|
|
||||||
|
package com.dsideal.tWxRecord;
|
||||||
|
|
||||||
|
import com.jfinal.plugin.activerecord.Model;
|
||||||
|
import com.jfinal.plugin.activerecord.TableMapping;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 自动生成的Model
|
||||||
|
* @author 石啸天
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class Twxrecord extends Model<Twxrecord> {
|
||||||
|
//--------------setter和getter---------------
|
||||||
|
|
||||||
|
public Twxrecord setStationName(String stationName) {
|
||||||
|
set("station_name", stationName);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStationName() {
|
||||||
|
return get("station_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setConnectorno(String connectorno) {
|
||||||
|
set("connectorNo", connectorno);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConnectorno() {
|
||||||
|
return get("connectorNo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setTypeName(String typeName) {
|
||||||
|
set("type_name", typeName);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return get("type_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setCreateTime(Timestamp createTime) {
|
||||||
|
set("create_time", createTime);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getCreateTime() {
|
||||||
|
return get("create_time");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setConnectorid(Integer connectorid) {
|
||||||
|
set("connectorId", connectorid);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getConnectorid() {
|
||||||
|
return get("connectorId");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setTypeId(Integer typeId) {
|
||||||
|
set("type_id", typeId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTypeId() {
|
||||||
|
return get("type_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setStationId(Integer stationId) {
|
||||||
|
set("station_id", stationId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStationId() {
|
||||||
|
return get("station_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setMemo(String memo) {
|
||||||
|
set("memo", memo);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemo() {
|
||||||
|
return get("memo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setEquipmentid(Integer equipmentid) {
|
||||||
|
set("equipmentId", equipmentid);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEquipmentid() {
|
||||||
|
return get("equipmentId");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setWxOpenid(String wxOpenid) {
|
||||||
|
set("wx_openid", wxOpenid);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWxOpenid() {
|
||||||
|
return get("wx_openid");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setStatusId(Integer statusId) {
|
||||||
|
set("status_id", statusId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatusId() {
|
||||||
|
return get("status_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setEquipmentname(String equipmentname) {
|
||||||
|
set("equipmentName", equipmentname);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEquipmentname() {
|
||||||
|
return get("equipmentName");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Twxrecord setId(Integer id) {
|
||||||
|
set("id", id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return get("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------
|
||||||
|
/***
|
||||||
|
*数据库操作实体
|
||||||
|
*/
|
||||||
|
public static final Twxrecord dao = new Twxrecord();
|
||||||
|
/**
|
||||||
|
* 表名
|
||||||
|
*/
|
||||||
|
public static final String tableName = "tWxRecord";
|
||||||
|
/**
|
||||||
|
* 表主键
|
||||||
|
*/
|
||||||
|
public static final String[] primaryKey = TableMapping.me().getTable(dao.getClass()).getPrimaryKey();
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 空构造
|
||||||
|
*/
|
||||||
|
public Twxrecord() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 有参构造
|
||||||
|
*/
|
||||||
|
public Twxrecord(
|
||||||
|
String stationName,
|
||||||
|
String connectorno,
|
||||||
|
String typeName,
|
||||||
|
Timestamp createTime,
|
||||||
|
Integer connectorid,
|
||||||
|
Integer typeId,
|
||||||
|
Integer stationId,
|
||||||
|
String memo,
|
||||||
|
Integer equipmentid,
|
||||||
|
String wxOpenid,
|
||||||
|
Integer statusId,
|
||||||
|
String equipmentname,
|
||||||
|
Integer id
|
||||||
|
) {
|
||||||
|
setData(
|
||||||
|
stationName,
|
||||||
|
connectorno,
|
||||||
|
typeName,
|
||||||
|
createTime,
|
||||||
|
connectorid,
|
||||||
|
typeId,
|
||||||
|
stationId,
|
||||||
|
memo,
|
||||||
|
equipmentid,
|
||||||
|
wxOpenid,
|
||||||
|
statusId,
|
||||||
|
equipmentname,
|
||||||
|
id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
*数据批量设置
|
||||||
|
*/
|
||||||
|
public Twxrecord setData(
|
||||||
|
String stationName,
|
||||||
|
String connectorno,
|
||||||
|
String typeName,
|
||||||
|
Timestamp createTime,
|
||||||
|
Integer connectorid,
|
||||||
|
Integer typeId,
|
||||||
|
Integer stationId,
|
||||||
|
String memo,
|
||||||
|
Integer equipmentid,
|
||||||
|
String wxOpenid,
|
||||||
|
Integer statusId,
|
||||||
|
String equipmentname,
|
||||||
|
Integer id) {
|
||||||
|
set("station_name", stationName);
|
||||||
|
set("connectorNo", connectorno);
|
||||||
|
set("type_name", typeName);
|
||||||
|
set("create_time", createTime);
|
||||||
|
set("connectorId", connectorid);
|
||||||
|
set("type_id", typeId);
|
||||||
|
set("station_id", stationId);
|
||||||
|
set("memo", memo);
|
||||||
|
set("equipmentId", equipmentid);
|
||||||
|
set("wx_openid", wxOpenid);
|
||||||
|
set("status_id", statusId);
|
||||||
|
set("equipmentName", equipmentname);
|
||||||
|
set("id", id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 按ID逆序查询全部数据
|
||||||
|
* 出现SQL注入漏洞
|
||||||
|
* @param pageNumber 页码
|
||||||
|
* @param pageSize 每页记录数
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public Map<String, Object> paginate(int pageNumber, int pageSize, String para, Object value) throws Exception {
|
||||||
|
Object[] o = new Object[]{};
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append("from " + tableName);
|
||||||
|
if (value != null && value != null && value != "") {
|
||||||
|
o = new Object[]{value};
|
||||||
|
sb.append(" where " + para + "=?");
|
||||||
|
}
|
||||||
|
sb.append(" order by " + primaryKey + " DESC");
|
||||||
|
Long num = Db.queryLong("select count(1) " + sb.toString(), o);
|
||||||
|
List<?> data = paginate(pageNumber, pageSize, "select *", sb.toString(), o).getList();
|
||||||
|
Map<String, Object> m = new HashMap<String, Object>();
|
||||||
|
m.put("data", data);
|
||||||
|
m.put("num", num);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue