⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huankegoodsdb.java

📁 cwbbs 云网论坛源码
💻 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 HuankeGoodsDb extends ObjectDb{    public static final int HUANKE_GOOD_STATUS_STOCKS = 0;     public static final int HUANKE_GOOD_STATUS_EXCHANGE = 1;     public static final int HUANKE_GOOD_STATUS_EXCHANGED = 2;     public HuankeGoodsDb() {    }    public HuankeGoodsDb(long msgRootId) {        this.msgRootId = msgRootId;        init();        load();    }    public void initDB() {        this.tableName = "plugin_huanke_goods";        primaryKey = new PrimaryKey("msgRootId", PrimaryKey.TYPE_LONG);        objectCache = new HuankeGoodsCache(this);        this.QUERY_CREATE = "insert into " + tableName + "(msg_root_id, catalog_code, goods, depreciation, contact, province, price, exchange_province, exchange_condition, exchange_catalog_code, exchange_goods, exchange_description, status, submit_date, user_name) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";        this.QUERY_SAVE = "update " + tableName + " set catalog_code=?, goods=?, depreciation=?, contact=?, province=?, price=?, exchange_province=?, exchange_condition=?, exchange_catalog_code=?, exchange_goods=?, exchange_description=?, status=?, msg_id=? where msg_root_id=?";        this.QUERY_DEL = "delete from " + tableName + " where msg_root_id=?";        this.QUERY_LOAD =            "select catalog_code, goods, depreciation, contact, province, price, exchange_province, exchange_condition, exchange_catalog_code, exchange_goods, exchange_description, status, submit_date, user_name, msg_id from " + tableName + " where msg_root_id=?";        isInitFromConfigDB = false;    }    public ObjectDb getObjectRaw(PrimaryKey pk) {        return new HuankeGoodsDb(pk.getLongValue());    }    public HuankeGoodsDb getHuankeGoodsDb(long id) {        return (HuankeGoodsDb) 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, msgRootId);            primaryKey.setValue(new Long(msgRootId));            rs = conn.executePreQuery();            if (rs.next()) {                catalogCode = rs.getString(1);                goods = rs.getString(2);                depreciation = rs.getString(3);                contact = rs.getString(4);                province = rs.getString(5);                price = rs.getString(6);                exchangeProvince = rs.getString(7);                exchangeCondition = rs.getString(8);                exchangeCatalogCode = rs.getString(9);                exchangeGoods = rs.getString(10);                exchangeDescription = rs.getString(11);                status = rs.getInt(12);                submitDate = rs.getString(13);                userName = rs.getString(14);                msgId = rs.getLong(15);                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, msgRootId);            ps.setString(2, catalogCode);            ps.setString(3, goods);            ps.setString(4, depreciation);            ps.setString(5, contact);            ps.setString(6, province);            ps.setString(7, price);            ps.setString(8, exchangeProvince);            ps.setString(9, exchangeCondition);            ps.setString(10, exchangeCatalogCode);            ps.setString(11, exchangeGoods);            ps.setString(12, exchangeDescription);            status = HuankeGoodsDb.HUANKE_GOOD_STATUS_EXCHANGE;            ps.setInt(13, status);            submitDate = Long.toString(System.currentTimeMillis());            ps.setString(14, submitDate);            ps.setString(15, userName);            rowcount = conn.executePreUpdate();        } catch (SQLException e) {            logger.error("create:" + e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }            HuankeGoodsCache hgc = new HuankeGoodsCache(this);            hgc.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.setString(1, catalogCode);            ps.setString(2, goods);            ps.setString(3, depreciation);            ps.setString(4, contact);            ps.setString(5, province);            ps.setString(6, price);            ps.setString(7, exchangeProvince);            ps.setString(8, exchangeCondition);            ps.setString(9, exchangeCatalogCode);            ps.setString(10, exchangeGoods);            ps.setString(11, exchangeDescription);            ps.setInt(12, status);            ps.setLong(13, msgId);            ps.setLong(14, msgRootId);            rowcount = conn.executePreUpdate();        } catch (SQLException e) {            logger.error("save:" + e.getMessage());            throw new ResKeyException(SkinUtil.ERR_DB);        } finally {            HuankeGoodsCache hgc = new HuankeGoodsCache(this);            primaryKey.setValue(new Long(msgRootId));            hgc.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, msgRootId);            rowcount = conn.executePreUpdate();        } catch (SQLException e) {            logger.error("del:" + e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        if (rowcount > 0) {            HuankeGoodsCache hgc = new HuankeGoodsCache(this);            primaryKey.setValue(new Long(msgRootId));            hgc.refreshDel(primaryKey);        }        return rowcount>0? true:false;    }    public void setMsgRootId(long msgRootId) {        this.msgRootId = msgRootId;    }    public void setCatalogCode(String catalogCode) {        this.catalogCode = catalogCode;    }    public void setGoods(String goods) {        this.goods = goods;    }    public void setContact(String contact) {        this.contact = contact;    }    public void setProvince(String province) {        this.province = province;    }    public void setPrice(String price) {        this.price = price;    }    public void setExchangeProvince(String exchangeProvince) {        this.exchangeProvince = exchangeProvince;    }    public void setExchangeCondition(String exchangeCondition) {        this.exchangeCondition = exchangeCondition;    }    public void setExchangeGoods(String exchangeGoods) {        this.exchangeGoods = exchangeGoods;    }    public void setExchangeDescription(String exchangeDescription) {        this.exchangeDescription = exchangeDescription;    }    public void setUserName(String userName) {        this.userName = userName;    }    public void setSubmitDate(String submitDate) {        this.submitDate = submitDate;    }    public void setStatus(int status) {        this.status = status;    }    public void setDepreciation(String depreciation) {        this.depreciation = depreciation;    }    public void setExchangeCatalogCode(String exchangeCatalogCode) {        this.exchangeCatalogCode = exchangeCatalogCode;    }    public void setMsgId(long msgId) {        this.msgId = msgId;    }    public long getMsgRootId() {        return msgRootId;    }    public String getCatalogCode() {        return catalogCode;    }    public String getGoods() {        return goods;    }    public String getContact() {        return contact;    }    public String getProvince() {        return province;    }    public String getPrice() {        return price;    }    public String getExchangeProvince() {        return exchangeProvince;    }    public String getExchangeCondition() {        return exchangeCondition;    }    public String getExchangeGoods() {        return exchangeGoods;    }    public String getExchangeDescription() {        return exchangeDescription;    }    public String getUserName() {        return userName;    }    public String getSubmitDate() {        return submitDate;    }    public int getStatus() {        return status;    }    public String getDepreciation() {        return depreciation;    }    public String getExchangeCatalogCode() {        return exchangeCatalogCode;    }    public long getMsgId() {        return msgId;    }    private long msgRootId;    private String catalogCode;    private String goods;    private String contact;    private String province;    private String price;    private String exchangeProvince;    private String exchangeCondition;    private String exchangeGoods;    private String exchangeDescription;    private String userName;    private String submitDate;    private int status;    private String depreciation;    private String exchangeCatalogCode;    private long msgId;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -