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

📄 clubtopicmanage.java

📁 GamVan Club v1.1 源代码
💻 JAVA
字号:
/*
 * ClubTopicManage.java
 * Created on 2005年1月5日, 下午3:49
 */
package com.gamvan.club.topic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.gamvan.club.ClubClassInfo;
import com.gamvan.club.ClubUsers;
import com.gamvan.conn.ConnClub;
import com.gamvan.club.topic.ClubTopicLog;
public class ClubTopicManage {
    private String act = new String();
    private int topicID, topicPro, moveCCID, ccID, topicOrder, userID=0;
    private double userMark=0, userMoney=0, userCredit=0;
    private String message = new String();
    private String message2 = new String();
    private String userName, byUser, saveLink;
    private String ccName="";
    
    //日至相关变量声明 
    private int byUserID=0;
    private String byUserIP="";
	private String topicLogTxt = ""; //日志备注
	private String topic="";
	private String topicLogSo="";
	private int topicLogList = 0, topicLogByUserList=0; //日志信息是否显示在网页底部
    ConnClub bridge = new ConnClub();
    ClubUsers cu = new ClubUsers();
    //ClubCounter ccu = new ClubCounter();
    ClubTopicInfo cti = new ClubTopicInfo();

    //格式化当前时间
    java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String now = isNow.format(new java.util.Date());
    
    public boolean topicLog(int tID) throws Exception{
    	boolean bea = false;
    	try{
    		//日至对象
	        ClubTopicLog ctl = new ClubTopicLog();
	        ctl.setTopicID(tID);
	        ctl.setTopic(topic);
	        ctl.setUserName(userName);
	        ctl.setUserID(userID);
	        ctl.setTopicLogByUserName(byUser);
	        ctl.setTopicLogByUserID(byUserID);
	        ctl.setTopicLogByUserIP(byUserIP);
	        ctl.setTopicLogTxt(topicLogTxt);
	        ctl.setUserCredit(userCredit);
	        ctl.setUserMark(userMark);
	        ctl.setUserMoney(userMoney);
	        ctl.setTopicLogSo(topicLogSo);
	        ctl.setTopicLogList(topicLogList);
	        ctl.setTopicLogByUserList(topicLogByUserList);
	        bea = ctl.executeLog();
	        message2 = ctl.getMessage();
    	}catch(Exception e){
    		message2 = e.toString();
    	}
    	return bea;
    }
    
    public boolean topicManage(String act, int tID) throws Exception{
        boolean bea = false;
        bea = cti.topicInfo(tID);
        topicPro = cti.getTopicPro();
        if(bea && topicPro!=4){
        	if(act.equals("manage")){ // log
                userName = cti.getUserName();
                userID = cti.getUserID();
                topic = cti.getTopic();
                topicLogSo = "奖/惩";                	
                bea = topicLog(tID);  
                if(bea){
                	bea = cu.userUpdate(userID, userMark, userMoney, userCredit, 0, 0);
                	if(!bea){
                		this.message = cu.getMessage();
                	}
                }
                this.message = message2; 	
        	}else if(act.equals("del")){
                bea = topicInfoUpdate(tID, 4, 0);
                if(bea){
                	userName = cti.getUserName();
                    userID = cti.getUserID();
                    topic = cti.getTopic();
                    topicLogSo = "删除主题";                	
                    bea = topicLog(tID);    //写入日志  
                    if(bea){
	                    message = cti.getTopic() + "<br /><br />主题删除操作成功!<br /><br />";
			            if(cti.getTopicLayer()==0){ //判断所要操作的帖子是主题还是回复
			            	cu.userUpdate(userID, userMark, userMoney, userCredit, 0, -1);
			            }else{
				            cu.userUpdate(userID, userMark, userMoney, userCredit, 1, -1);
			            }
                    }
                    this.message += this.message2;
                }else{
                    message= "主题删除操作失败!";
                }
            }else if(act.equals("best")){
                if(topicPro!=1){
                    bea = topicInfoUpdate(tID, 1,0);
                    if(bea){
                        userName = cti.getUserName();
                        userID = cti.getUserID();
                        topic = cti.getTopic();
                        topicLogSo = "精品归档";                	
                        bea = topicLog(tID);    //写入日志   
                        if(bea){ //判断日志是否正确写入
                        	bea = cu.userUpdate(userID, userMark, userMoney, userCredit, 3, 0);
                        	if(bea){ //判断用户参数是否正确更新
                        		this.message = cti.getTopic() + "<br /><br />主题已被加为精品!<br /><br />";
                        	}
                        }
                        this.message += this.message2;
                        
                    }else{
                    	this.message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!";
                    }
                }else{
                    message = cti.getTopic() + "<br /><br />主题已经是精品文章,请不要重复操作!<br /><br />";
                }
            }else if(act.equals("nobest")){
                if(topicPro==1){
                    bea = topicInfoUpdate(tID,0,0);
                    if(bea){
                        userName = cti.getUserName();
                        userID = cti.getUserID();
                        topic = cti.getTopic();
                        topicLogSo = "取消精品归档";                	
                        bea = topicLog(tID); //写入日志
                        if(bea){  //判断日志是否正确写入
	                        bea = cu.userUpdate(userID, userMark, userMoney, userCredit, 3, 0);
	                        if(bea){  //判断用户参数是否正确更新
	                            this.message = cti.getTopic() + "<br /><br />文章精品属性已被取消!<br /><br />";
	                        }
                        }
                        this.message += message2;
                    }else{
                        message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!";
                    }
                }else{
                    message = cti.getTopic() + "<br /><br />该主题属性已经不是精品,请不要重复操作!<br /><br />";
                }
            }else if(act.equals("move")){
                        bea = topicMove(tID,moveCCID);
                    if(bea){    
                        userName = cti.getUserName();
                        userID = cti.getUserID();
                        topic = cti.getTopic();
                        //topicLogSo = 已定义
                        bea = topicLog(tID); //写入日志     
                        if(bea){
                        	bea = cu.userUpdate(userID, userMark, userMoney, userCredit, 3, 0);
                        	if(bea){
                        		this.message = cti.getTopic() + "<br /><br />文章移动成功!<br /><br />";
                        	}
                        }
                        this.message += message2;
                    }else{
                        message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!";
                    }
            }else if(act.equals("top")){
                    bea = topicInfoUpdate(tID, topicOrder, 1);
                    if(bea){
                        userName = cti.getUserName();
                        userID = cti.getUserID();
                        topic = cti.getTopic();
                        topicLogSo = "文章置顶";                	
                        bea = topicLog(tID); //写入日志
                        if(bea){  //判断日志是否正确写入
                        	bea = cu.userUpdate(userID, userMark, userMoney, userCredit, 3, 0);
                        	if(bea){
                        		message = cti.getTopic() + "<br /><br />置顶操作成功!<br /><br />";
                        	}
                        }
                        this.message += message2;
                    }else{
                        message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!";
                    }
            }
            
        }else{
            message= "您所请求的操作的文章不存在!";
        }
        return bea;
    }
    public boolean topicMove(int tID, int moveID) throws Exception{
        boolean bea = false;
        int ccidd;
        int ccid1=0, ccid2=0;
        int ccidd1=0, ccidd2=0;
        ClubClassInfo cci = new ClubClassInfo();
        cci.classInfo(moveID);
        topicLogSo = "从 " + ccName + " 移动到 " + cci.getName();
        ccidd = cci.getIDD();
        if(ccidd>0){
            cci.classInfo(ccidd);
            ccid1 = ccidd;
            ccidd1 = cci.getIDD();
            if(ccidd1>0){
                ccid2 = ccidd1;
            }
        }
        Connection con = bridge.getConnection();
        try{
            String sqlCommand = new String();
            sqlCommand = "Update GVclubTopic set ccID=?, ccID2=?, ccID1=?, moveCCID=?, moveUser=?, moveTime=? where topicID=?";
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1, moveID);
            pps.setInt(2, ccid2);
            pps.setInt(3, ccid1);
            if(saveLink.equals("1")){
                pps.setInt(4, ccID);
            }else{
                pps.setInt(4, 0);
            }
            pps.setString(5, byUser);
            pps.setString(6, now);
            pps.setInt(7, tID);
            pps.executeUpdate();
            pps.close();
            con.close();
            bea = true;
            message= "主题移动成功!";
        }catch(Exception e){
            message= "您的操作触发一个美丽的意外,将不被执行,请重新尝试!";
            bea = false;
        }finally{
            con.close();
        }
        return bea;
    }
    public boolean topicInfoUpdate (int tID, int num, int what) throws Exception{
        boolean bea = false;
        String sqlCommand = new String();
        Connection con = bridge.getConnection();
        try{
            sqlCommand = "Update GVclubTopic set ";
            if(what==0){
                sqlCommand += " topicPro=? ";
            }else if(what==1){
                sqlCommand += " topicOrder=? ";
            }
            if(tID!=0){
                sqlCommand += " where topicID=?";
            }
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1, num);
            pps.setInt(2, tID);
            pps.executeUpdate();
            bea = true;
            pps.close();
        }catch(Exception e){
            message="抱歉!由于系统运行出现一个美丽的错误,您的操作将不能被执行,请重新尝试!";
            bea = false;
            con.close();
        }finally{
            con.close();
        }
        return bea;
    }
    public String getMessage(){
        return this.message;
    }
    //日至相关
    public void setTopicLogTxt(String topicLogTxt){
    	this.topicLogTxt = topicLogTxt;
    }
    public void setTopicLogSo(String topicLogSo){
    	this.topicLogSo = topicLogSo;
    }
    //
    public void setSaveLink(String saveLink){
        this.saveLink = saveLink;
    }
    public void setByUser(String byUser){
        this.byUser = byUser;
    } 
    public void setByUserID(int userID){
    	this.byUserID = userID;
    }
    public void setByUserIP(String userIP){
    	this.byUserIP = userIP;
    }
    public void setUserMark(String userMark){
        if(userMark!=null){
            this.userMark = Double.parseDouble(userMark);
        }else{
            this.userMark = 0;
        }
    }
    public void setTopicOrder(String topicOrder){
        if(topicOrder!=null){
            this.topicOrder = Integer.parseInt(topicOrder);
        }else{
            this.topicOrder = 0;
        }
    }
    public void setCCNAME(String ccName){
    	this.ccName = ccName;
    }
    public void setCCID(int ccID){
      this.ccID = ccID;
    }
    public void setMoveCCID(String ccid){
        if(ccid==null){
            this.moveCCID = 0;
        }else{
            this.moveCCID = Integer.parseInt(ccid);
        }
    }
    public void setUserMoney(String userMoney){
        if(userMoney!=null){
            this.userMoney = Double.parseDouble(userMoney);
        }else{
            this.userMoney=0;
        }
    }    
    public void setUserCredit(String userCredit){
        if(userCredit!=null){ 
            this.userCredit = Double.parseDouble(userCredit);
        }else{
            this.userCredit = 0;
       } 
    }
	public void setTopicLogByUserList(int topicLogByUserList){
		this.topicLogByUserList = topicLogByUserList;
	}
	public void setTopicLogList(int topicLogList){
		this.topicLogList = topicLogList;
	}
}

⌨️ 快捷键说明

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