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

📄 auctionboarddb.java

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA
字号:
package com.redmoon.forum.plugin.auction;

import java.sql.*;

import cn.js.fan.base.ObjectDb;
import cn.js.fan.db.Conn;
import cn.js.fan.db.PrimaryKey;

public class AuctionBoardDb extends ObjectDb {

    public AuctionBoardDb() {
        init();
    }

    public AuctionBoardDb(String boardCode) {
        this.boardCode = boardCode;
        init();
        load();
    }

    public boolean create(String boardCode, String auctionRule) {
        int rowcount = 0;
        Conn conn = null;
        try {
            conn = new Conn(connname);
            PreparedStatement ps = conn.prepareStatement(this.QUERY_CREATE);
            ps.setString(1, boardCode);
            ps.setString(2, auctionRule);
            rowcount = conn.executePreUpdate();
        } catch (SQLException e) {
            logger.error("create:" + e.getMessage());
        } finally {
            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.setString(1, boardCode);
            rowcount = conn.executePreUpdate();

            AuctionBoardCache sc = new AuctionBoardCache(this);
            sc.refreshDel(primaryKey);
        } catch (SQLException e) {
            logger.error(e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount > 0 ? true : false;
    }

    public AuctionBoardDb getAuctionBoardDb(String boardCode) {
        return (AuctionBoardDb)getObjectDb(boardCode);
    }

    public ObjectDb getObjectDb(Object primaryKeyValue) {
        AuctionBoardCache sc = new AuctionBoardCache(this);
        primaryKey.setValue(primaryKeyValue);
        return sc.getObjectDb(primaryKey);
    }

    public int getObjectCount(String sql) {
        return 0;
    }

    public ObjectDb getObjectRaw(PrimaryKey pk) {
         return new AuctionBoardDb(pk.getStrValue());
    }

    public void setQueryCreate() {
        this.QUERY_CREATE = "insert plugin_auction_board (boardCode, auctionRule) values (?, ?)";
    }

    public void setQuerySave() {
        this.QUERY_SAVE = "update plugin_auction_board set auctionRule=? where boardCode=?";
    }

    public void setQueryDel() {
        this.QUERY_DEL = "delete from plugin_auction_board where boardCode=?";
    }

    public void setQueryLoad() {
        this.QUERY_LOAD =
            "select auctionRule from plugin_auction_board where boardCode=?";
    }

    public void setQueryList() {
        this.QUERY_LIST = "select boardCode from plugin_auction_board";
    }

    public boolean save() {
        int rowcount = 0;
        Conn conn = null;
        try {
            conn = new Conn(connname);
            PreparedStatement ps = conn.prepareStatement(QUERY_SAVE);
            ps.setString(1, auctionRule);
            ps.setString(2, boardCode);
            rowcount = conn.executePreUpdate();

            AuctionBoardCache uc = new AuctionBoardCache(this);
            primaryKey.setValue(boardCode);
            uc.refreshSave(primaryKey);
        } catch (SQLException e) {
            logger.error(e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount>0? true:false;
    }

    public void load() {
        ResultSet rs = null;
        Conn conn = new Conn(connname);
        try {
            PreparedStatement ps = conn.prepareStatement(this.QUERY_LOAD);
            ps.setString(1, boardCode);
            rs = conn.executePreQuery();
            if (rs.next()) {
                auctionRule = rs.getString(1);
                primaryKey.setValue(boardCode);
                loaded = true;
            }
        } catch (SQLException e) {
            logger.error("load:" + e.getMessage());
        }
        finally {
            if (conn!=null) {
                conn.close();
                conn = null;
            }
        }
    }

    public Object[] getObjectBlock(String query, int startIndex) {
        return null;
    }

    public void setPrimaryKey() {
        this.primaryKey = new PrimaryKey("boardCode", primaryKey.TYPE_STRING);
    }

    public void setAuctionRule(String auctionRule) {
        this.auctionRule = auctionRule;
    }

    public void setBoardCode(String boardCode) {
        this.boardCode = boardCode;
    }

    public void setSkinCode(String skinCode) {
        this.skinCode = skinCode;
    }

    public String getAuctionRule() {
        return auctionRule;
    }

    public String getBoardCode() {
        return boardCode;
    }

    public String getSkinCode() {
        return "default";
        // return skinCode;
    }

    private String auctionRule; // 本版关于情人路的规则

    private String boardCode;
    /**
     * isPluginBoard
     */
    public boolean isPluginBoard(String boardCode) {
        AuctionBoardDb sb = (AuctionBoardDb)getObjectDb(boardCode);
        if (sb.isLoaded())
            return true;
        else
            return false;
    }

    private String skinCode;
}

⌨️ 快捷键说明

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