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

📄 clubtopicinfo.java

📁 GamVan Club v1.1 源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.gamvan.club.topic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.gamvan.club.ClubUsers;
import com.gamvan.conn.ConnClub;
public class ClubTopicInfo{
    private String message;
    private String userName, userPass, userPass2, typeUserName; //型别记录的用户名
    private int topicID, topicReID;
    private String topicAddip;
    private String topic, content="";
    private int contentUserPen=0, contentUrl=0, contentImg=0, contentEmail=0, contentCopyRight=0;
    private String contentEditInfo; //编辑信息。
    private String contentReUser; //回复过主题的用户
    private String topicList;
    private int topicType, topicMood, topicPro;//topicPro 锁定、禁止回复、精品。
    private int ccID, ccID1, ccID2, moveCCID; //所在分类,moveCCID移动自某分类。
    private int topicTypeUserInfo; //购买、积分、求助特殊类型的主题关联的用户积分,金币得失情况
    private int topicTypeInfo; //购买、积分、求助特殊类型的主题日志发生时该主题的类型
    private int topicTypeNum; //特殊类型主题关联的积分或金币
    private String topicTypeUsers, topicAddTime; //购买、积分、求助特殊类型的主题关联的用户
    private String topicLastReUser, topicLastReTime;
    private int topicViewCount, topicReCount;
    private int topicTree, topicLayer, topicOrder; //topicOrder主题排序,可固定,回复树形排序
    private String act; //判断是编辑、添加、修过或是删除
    private double userMark, userCredit, userMoney;
    private String reUsers="";
    private int userID = 0, topicLen=0;
    ConnClub bridge = new ConnClub();
    ClubUsers cu = new ClubUsers();
    
    //创建于2005/5/16 更新订阅主题的最后查看时间
    public boolean updateMyLike(int topicid, int userid) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        String sqlCommand = new String();
        if(userid>0&&topicid>0){
            //格式化当前时间
            java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String now = isNow.format(new java.util.Date());
            try{
                sqlCommand = "Update GVclubTopicIlike set lastTime=? where topicID=? and myUserID=?";
                PreparedStatement pps = con.prepareStatement(sqlCommand);
                pps.setString(1,now);
                pps.setInt(2,topicid);
                pps.setInt(3,userid);
                pps.executeUpdate();
                pps.close();
                bea = true;
            }catch(Exception e){

            }finally{
                con.close();
            }
        }
        return bea;
    }

    
    public double selectTopicType(int tid, int userid, int typeinfo, double typenum) throws Exception{
        double du = 0;
        String sqlCommand = new String();
        ResultSet rs;
        Connection con = bridge.getConnection();
        try{
            sqlCommand = "Select * From GVclubTopicType where topicID=? and typeInfo=?  and userID=?";
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1, tid);  
            pps.setInt(2, typeinfo);
            pps.setInt(3, userid);
            rs = pps.executeQuery();
            if(rs.next()){
                du = rs.getFloat(4);
            }else{
                du = 0;
            }
            rs.close();
            pps.close();
        }catch(Exception e){
            du = 0;
            con.close();
        }finally{
            con.close();
        }
        return du;
    }
    /* 当用户没有购买过当前主题时执行添加操作
     * addTopicType
     */
    public boolean addTopicType(int tid, int userid, int typeinfo,double typenum)
    throws Exception{
        String sqlCommand = new String();
        boolean bea = false;
        java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String now = isNow.format(new java.util.Date());
        if(userid>0){
        if(typenum!=0){
            Connection con = bridge.getConnection();
        try{
            if(typeinfo==2){ //金钱贴扣除用户今币
                cu.userSelect(userid);
                typeUserName = cu.getUserName();
                if(cu.getUserMoney()<typenum){
                    message = "您的金币不足,而且无法透支,本次交易失败!";
                }else{
                    // 扣除购买人的金币
                    cu.userUpdate(userid,0,-typenum,0,3,0); 
                    // 给帖子主人增加收入
                    if(topicInfo(tid)){
                        cu.userUpdate(this.userID,0,typenum,0,3,0);
                    }
                    //………………………………
                    bea = true;
                    sqlCommand = "Insert into GVclubTopicType(topicID, typeInfo, typeNum, userName, addTime, userID)";
                    sqlCommand += " Values(?,?,?,?,?,?)";
                    PreparedStatement pps = con.prepareStatement(sqlCommand);
                    pps.setInt(1,tid);
                    pps.setInt(2,typeinfo);
                    pps.setDouble(3,typenum);
                    pps.setString(4,typeUserName);
                    pps.setString(5,now);
                    pps.setInt(6, userid);
                    pps.executeUpdate();
                    pps.close();
                }
            }
        }catch(Exception e){
            con.close();
            message = e.toString() + "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!";
        }finally{
            con.close();
        }
        }
        }else{
            message = "您尚未登陆,或登陆超时!请重新登陆!";
        }
        return bea;
    }
    /* 当用户购买过主题执行更新操作
     * updateTopicType
     */
    public boolean updateTopicType(int tid, int userid, int typeinfo, double typenum)
    throws Exception{
        String sqlCommand = new String();
        boolean bea = false;
        java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String now = isNow.format(new java.util.Date());
        if(userid>0){
        Connection con = bridge.getConnection();
        try{
            if(typeinfo==2){ 
                cu.userSelect(userid);
                typeUserName = cu.getUserName();
                typenum=typenum-selectTopicType(tid, userid, typeinfo, typenum);
                if(cu.getUserMoney()<typenum){ // 判断用户所有金币是否足够购买本贴
                    message = "您的金币不足,而且无法透支,本次交易失败!";
                }else{
                    // 返回已经支付过的金额 selectTopicType(tid, username, typeinfo, typenum);
                    //金钱贴扣除购买用户今币.
                    cu.userUpdate(userid,0,-typenum,0,3,0);
                    // 给帖子主人增加收入
                    if(topicInfo(tid)){
                        cu.userUpdate(this.userID,0,typenum,0,3,0);
                    }
                   // message = String.valueOf(userid);
                    //………………………………
                    bea = true; //购买成功
                    sqlCommand = "update GVclubTopicType set typeNum=typeNum+?, addTime=?, userName=? where userID=? and topicID=? and typeInfo=?";
                    PreparedStatement pps = con.prepareStatement(sqlCommand);
                    pps.setDouble(1,typenum);
                    pps.setString(2,now);
                    pps.setString(3,typeUserName);
                    pps.setInt(4,userid);
                    pps.setInt(5,tid);
                    pps.setInt(6,typeinfo);
                    pps.executeUpdate();
                    pps.close();
                }
            }
        }catch(Exception e){
            message = e.toString() + "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!";
            con.close();
        }finally{
            con.close();
        }
        }else{
            message = "您尚未登陆,或登陆超时!请重新登陆!";
        }
        return bea;
    }
    public boolean selectReUsers(int tID) throws Exception{
        String sqlCommand = new String();
        ResultSet rs;
        boolean bea = false;
        Connection con = bridge.getConnection();
        try{
            sqlCommand = "Select * From GVclubTopicReUsers where topicID=?";
            PreparedStatement pps = con.prepareStatement(sqlCommand);
            pps.setInt(1, tID);  
            rs = pps.executeQuery();
            if(rs.next()){
                reUsers = rs.getString(3).trim();
                bea = true;
            }else{
                bea = false;

⌨️ 快捷键说明

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