📄 huankereplydb.java
字号:
package com.redmoon.forum.plugin.huanke;import java.sql.*;import cn.js.fan.base.*;import cn.js.fan.db.*;import cn.js.fan.util.*;import cn.js.fan.web.*;public class HuankeReplyDb extends ObjectDb{ public static final int REPLY_TYPE_EXCHANGE = 0; public static final int REPLY_TYPE_COMMUNICATION = 1; public HuankeReplyDb() { } public HuankeReplyDb(long msgId) { this.msgId = msgId; init(); load(); } public void initDB() { this.tableName = "plugin_huanke_reply"; primaryKey = new PrimaryKey("msgId", PrimaryKey.TYPE_LONG); objectCache = new HuankeReplyCache(this); this.QUERY_CREATE = "insert into " + tableName + "(msg_id, reply_type, exchange_goods, exchange_catalog_code, exchange_depreciation, exchange_province, contact, exchange_user_name, submit_date) values (?,?,?,?,?,?,?,?,?)"; this.QUERY_SAVE = "update " + tableName + " set reply_type=?, exchange_goods=?, exchange_catalog_code=?, exchange_depreciation=?, exchange_province=?, contact=? where msg_id=?"; this.QUERY_DEL = "delete from " + tableName + " where msg_id=?"; this.QUERY_LOAD = "select reply_type, exchange_goods, exchange_catalog_code, exchange_depreciation, exchange_province, contact, exchange_user_name, submit_date from " + tableName + " where msg_id=?"; isInitFromConfigDB = false; } public ObjectDb getObjectRaw(PrimaryKey pk) { return new HuankeReplyDb(pk.getLongValue()); } public HuankeReplyDb getHuankeReplyDb(long id) { return (HuankeReplyDb) getObjectDb(new Long(id)); } public void load() { ResultSet rs = null; Conn conn = new Conn(connname); try { PreparedStatement ps = conn.prepareStatement(this.QUERY_LOAD); ps.setLong(1, msgId); primaryKey.setValue(new Long(msgId)); rs = conn.executePreQuery(); if (rs.next()) { replyType = rs.getInt(1); exchangeGoods = rs.getString(2); exchangeCatalogCode = rs.getString(3); exchangeDepreciation = rs.getString(4); exchangeProvince = rs.getString(5); contact = rs.getString(6); exchangeUserName = rs.getString(7); submitDate = rs.getString(8); loaded = true; } } catch (SQLException e) { logger.error("load:" + e.getMessage()); } finally { if (conn!=null) { conn.close(); conn = null; } } } public boolean create() { int rowcount = 0; Conn conn = null; try { conn = new Conn(connname); PreparedStatement ps = conn.prepareStatement(this.QUERY_CREATE); ps.setLong(1, msgId); ps.setInt(2, replyType); ps.setString(3, exchangeGoods); ps.setString(4, exchangeCatalogCode); ps.setString(5, exchangeDepreciation); ps.setString(6, exchangeProvince); ps.setString(7, contact); ps.setString(8, exchangeUserName); submitDate = Long.toString(System.currentTimeMillis()); ps.setString(9, submitDate); rowcount = conn.executePreUpdate(); } catch (SQLException e) { logger.error("create:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } HuankeReplyCache hrc = new HuankeReplyCache(this); hrc.refreshCreate(); } return rowcount > 0 ? true : false; } public boolean save() throws ResKeyException { int rowcount = 0; Conn conn = null; try { conn = new Conn(connname); PreparedStatement ps = conn.prepareStatement(this.QUERY_SAVE); ps.setInt(1, replyType); ps.setString(2, exchangeGoods); ps.setString(3, exchangeCatalogCode); ps.setString(4, exchangeDepreciation); ps.setString(5, exchangeProvince); ps.setString(6, contact); ps.setLong(7, msgId); rowcount = conn.executePreUpdate(); } catch (SQLException e) { logger.error("save:" + e.getMessage()); throw new ResKeyException(SkinUtil.ERR_DB); } finally { HuankeReplyCache hrc = new HuankeReplyCache(this); primaryKey.setValue(new Long(msgId)); hrc.refreshSave(primaryKey); if (conn != null) { conn.close(); conn = null; } } return rowcount>0? true:false; } public boolean del() { int rowcount = 0; Conn conn = null; try { conn = new Conn(connname); PreparedStatement ps = conn.prepareStatement(this.QUERY_DEL); ps.setLong(1, msgId); rowcount = conn.executePreUpdate(); } catch (SQLException e) { logger.error("del:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } if (rowcount > 0) { HuankeReplyCache hrc = new HuankeReplyCache(this); primaryKey.setValue(new Long(msgId)); hrc.refreshDel(primaryKey); } return rowcount>0? true:false; } public void setContact(String contact) { this.contact = contact; } public void setExchangeProvince(String exchangeProvince) { this.exchangeProvince = exchangeProvince; } public void setExchangeGoods(String exchangeGoods) { this.exchangeGoods = exchangeGoods; } public void setSubmitDate(String submitDate) { this.submitDate = submitDate; } public void setExchangeCatalogCode(String exchangeCatalogCode) { this.exchangeCatalogCode = exchangeCatalogCode; } public String getContact() { return contact; } public String getExchangeProvince() { return exchangeProvince; } public String getExchangeGoods() { return exchangeGoods; } public String getSubmitDate() { return submitDate; } public String getExchangeCatalogCode() { return exchangeCatalogCode; } public void setMsgId(long msgId) { this.msgId = msgId; } public void setReplyType(int replyType) { this.replyType = replyType; } public void setExchangeDepreciation(String exchangeDepreciation) { this.exchangeDepreciation = exchangeDepreciation; } public void setExchangeUserName(String exchangeUserName) { this.exchangeUserName = exchangeUserName; } public long getMsgId() { return msgId; } public int getReplyType() { return replyType; } public String getExchangeDepreciation() { return exchangeDepreciation; } public String getExchangeUserName() { return exchangeUserName; } private long msgId; private int replyType; private String exchangeGoods; private String exchangeCatalogCode; private String exchangeDepreciation; private String exchangeProvince; private String contact; private String exchangeUserName; private String submitDate;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -