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

📄 clubtopicdel.java

📁 GamVan Club v1.1 源代码
💻 JAVA
字号:
/*
 * ClubTopicDel.java
 * 回收站帖子清理bean
 * Made In GamVan
 * Created on 2005年5月11日, 下午11:03
 */
package com.gamvan.club.topic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.gamvan.club.ClubClassInfo;
import com.gamvan.club.ClubCounter;
import com.gamvan.conn.ConnClub;
public class ClubTopicDel {
    private String message = new String();
    ConnClub bridge = new ConnClub();
    ClubTopicInfo cti = new ClubTopicInfo();
    ClubCounter ccu = new ClubCounter();//社区统计
    ClubClassInfo cci = new ClubClassInfo();//社区主题、回复统计
    public boolean topicDels(String act, String[] ids) throws Exception{
        boolean bea = false;
        int id = 0;
        if(ids==null){
            message = "请选择你要操作的主题。";
            return false;
        }
        try{
            if(act.equals("1")){ //执行还原
                for(int i=0; i<ids.length; i++){
                 id = Integer.parseInt(ids[i]);
                    bea = topicBack(id);
                }
                //message = "还原操作成功!";
            }else if(act.equals("2")){ //执行删除文章
                for(int i=0; i<ids.length; i++){
                 id = Integer.parseInt(ids[i]);
                    bea = topicDel(id);
                }
                //message = "删除操作成功!";
            }else{
                message = "请选择您将要操作的内容!";
                bea = false;
            }
        }catch(Exception e){
            message = e.toString();
        }
        return bea;
    }
    //从回收站还原这个帖子。
    public boolean topicBack(int id) throws Exception{
        boolean bea = false;
        String sqlCommand = "";
        Connection con = bridge.getConnection();
        try{
            sqlCommand = "Update GVclubTopic set topicPro=0 where topicID=?";
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1,id);
            pps.executeUpdate();
            pps.close();
            bea = true;
            message = "文章还原成功";
        }catch(Exception e){
            message = e.toString();
            bea = false;
        }finally{
            con.close();
        }
        return bea;        
    }

    public boolean topicDel(int id) throws Exception{
        boolean bea = false;
        String userName = "";
        int userID = 0
        , ccID = 0, topicLayer=0;
        bea = cti.topicInfo(id);
        if(bea){
            userName = cti.getUserName();
            userID = cti.getUserID();
            ccID = cti.getCCID();
            topicLayer = cti.getTopicLayer(); //判断文章是主题还是回复
        }else{
            message = "主题不存在或已被删除!";
            return false;            
        }
        delCount(topicLayer, ccID); //更新社区统计信息
        bea = runDel(id);        
        return bea;
    }
    
    public void delCount(int isLayer, int ccid) throws Exception{
        String sqlCommand = "";
        Connection con = bridge.getConnection();
        try{
            if(isLayer==0){
                sqlCommand = "Update GVclubCounter set clubTopic = clubTopic - 1"; 
                PreparedStatement pps = con.prepareStatement(sqlCommand);
                pps.executeUpdate();
                pps.close();
                
                sqlCommand = "Update GVclubClass set  ccTopic = ccTopic-1 where ccID=?";
                PreparedStatement pps0 = con.prepareStatement(sqlCommand);
                pps0.setInt(1,ccid);
                pps0.executeUpdate();
                pps0.close();
            }else{
                sqlCommand = "Update GVclubCounter set clubReply = clubReply - 1"; 
                PreparedStatement pps = con.prepareStatement(sqlCommand);
                pps.executeUpdate();
                pps.close();
                
                sqlCommand = "Update GVclubClass set  ccReply = ccReply-1 where ccID=?";
                PreparedStatement pps0 = con.prepareStatement(sqlCommand);
                pps0.setInt(1,ccid);
                pps0.executeUpdate();
                pps0.close();
            }
        }catch(Exception e){
            message = e.toString();
            con.close();
        }finally{
            con.close();
        }
        
    }
    //执行删除
    public boolean runDel(int id) throws Exception{
        boolean bea = false;
        String sqlCommand = "";
        Connection con = bridge.getConnection();
        try{
            //删除帖子
            sqlCommand = "Delete From GVclubTopic where topicID=?";
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1, id);
            pps.executeUpdate();
            pps.close();
            
            //删除详细内容
            sqlCommand = "Delete From GVclubContent where topicID=?";
            PreparedStatement pps0 = con.prepareStatement(sqlCommand);
            pps0.setInt(1, id);
            pps0.executeUpdate();
            pps0.close();
            
            //删除该贴的回复人员名单信息
            sqlCommand="";
            sqlCommand = "Delete From GVclubTopicReUsers where topicID=?";
            PreparedStatement pps1 = con.prepareStatement(sqlCommand);
            pps1.setInt(1, id);
            pps1.executeUpdate();
            pps1.close();
            
            //删除该贴type信息
            sqlCommand="";
            sqlCommand = "Delete From GVclubTopicType where topicID=?";
            PreparedStatement pps2 = con.prepareStatement(sqlCommand);
            pps2.setInt(1, id);
            pps2.executeUpdate();
            pps2.close();
            bea = true;
            message = "文章删除成功!";
        }catch(Exception e){
            con.close();
            bea = false;
            message = e.toString();
        }finally{
            con.close();
        }
        return bea;
    }
    public String getMessage(){
        return this.message;
    }
}

⌨️ 快捷键说明

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