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

📄 rewardboarddb.java

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

import java.sql.*;

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

public class RewardBoardDb extends ObjectDb {

    public RewardBoardDb() {
        init();
    }

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

    public boolean create(String boardCode, String rule) {
        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, rule);
            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();
            RewardBoardCache sc = new RewardBoardCache(this);
            sc.refreshDel(primaryKey);
        } catch (SQLException e) {
            logger.error("del:" + e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount > 0 ? true : false;
    }

    public RewardBoardDb getRewardBoardDb(String boardCode) {
        return (RewardBoardDb)getObjectDb(boardCode);
    }

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

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

            RewardBoardCache uc = new RewardBoardCache(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()) {
                boardRule = StrUtil.getNullStr(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 void setPrimaryKey() {
        this.primaryKey = new PrimaryKey("boardCode", primaryKey.TYPE_STRING);
    }

    public void setBoardRule(String boardRule) {
        this.boardRule = boardRule;
    }

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

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

    public String getBoardRule() {
        return boardRule;
    }

    public String getBoardCode() {
        return boardCode;
    }

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

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

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

    public void initDB() {
        this.tableName = "plugin_reward_board";
        primaryKey = new PrimaryKey("boardCode", PrimaryKey.TYPE_STRING);
        objectCache = new RewardBoardCache(this);

        this.QUERY_CREATE = "insert into plugin_reward_board (boardCode, boardRule) values (?, ?)";
        this.QUERY_SAVE = "update plugin_reward_board set boardRule=? where boardCode=?";
        this.QUERY_DEL = "delete from plugin_reward_board where boardCode=?";
        this.QUERY_LOAD =
            "select boardRule from plugin_reward_board where boardCode=?";
        this.QUERY_LIST = "select boardCode from plugin_reward_board";
        isInitFromConfigDB = false;
    }

    private String skinCode;
}

⌨️ 快捷键说明

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