📄 clubtopicinfo.java
字号:
package com.gamvan.club.topic;import com.gamvan.conn.*;import com.gamvan.club.ClubRule;import com.gamvan.tools.*;import com.gamvan.club.ClubUsers;import java.sql.*;import java.util.*;public class ClubTopicInfo{ private String message; private String userName, userPass, userPass2; 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=""; ConnClub bridge = new ConnClub(); ClubUsers cu = new ClubUsers(); public double selectTopicType(int tid, String username, 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 userName=? and topicID=? and typeInfo=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setString(1, username); pps.setInt(2, tid); pps.setInt(3, typeinfo); rs = pps.executeQuery(); if(rs.next()){ du = rs.getFloat(4); } rs.close(); pps.close(); }catch(Exception e){ du = 0; con.close(); }finally{ con.close(); } return du; } /* 当用户没有购买过当前主题时执行添加操作 * addTopicType */ public boolean addTopicType(int tid, String username, 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(!username.equals("")&&username!=null){ if(typenum!=0){ Connection con = bridge.getConnection(); try{ if(typeinfo==2){ //金钱贴扣除用户今币 cu.userSelect(username); if(cu.getUserMoney()<typenum){ message = "您的金币不足,而且无法透支,本次交易失败!"; }else{ cu.userUpdate(username,0,-typenum,0,3,0); // 扣除购买人的金币 // 给帖子主人增加收入 if(topicInfo(tid)){ cu.userUpdate(this.userName,0,typenum,0,3,0); } //……………………………… bea = true; sqlCommand = "Insert into GVclubTopicType(topicID, typeInfo, typeNum, userName, addTime)"; sqlCommand += " Values(?,?,?,?,?)"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setInt(1,tid); pps.setInt(2,typeinfo); pps.setDouble(3,typenum); pps.setString(4,username); pps.setString(5,now); pps.executeUpdate(); pps.close(); } } }catch(Exception e){ con.close(); message = "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!"; }finally{ con.close(); } } }else{ message = "您尚未登陆,或登陆超时!请重新登陆!"; } return bea; } /* 当用户购买过主题执行更新操作 * updateTopicType */ public boolean updateTopicType(int tid, String username, 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(!username.equals("")&&username!=null){ Connection con = bridge.getConnection(); try{ if(typeinfo==2){ cu.userSelect(username); typenum=typenum-selectTopicType(tid, username, typeinfo, typenum); if(cu.getUserMoney()<typenum){ // 判断用户所有金币是否足够购买本贴 message = "您的金币不足,而且无法透支,本次交易失败!"; }else{ // 返回已经支付过的金额 selectTopicType(tid, username, typeinfo, typenum); cu.userUpdate(username,0,-typenum,0,3,0);//金钱贴扣除购买用户今币. // 给帖子主人增加收入 if(topicInfo(tid)){ cu.userUpdate(this.userName,0,typenum,0,3,0); } //……………………………… bea = true; //购买成功 sqlCommand = "update GVclubTopicType set typeNum=typeNum+?, addTime=? where userName=? and topicID=? and typeInfo=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setDouble(1,typenum); pps.setString(2,now); pps.setString(3,username); pps.setInt(4,tid); pps.setInt(5,typeinfo); pps.executeUpdate(); pps.close(); } } }catch(Exception e){ message = "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!"; 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; } rs.close(); pps.close(); }catch(Exception e){ bea = false; con.close(); }finally{ con.close(); } return bea; } public void topicUpdate(int tID, int i, int r) throws Exception{ String sqlCommand = new String(); ResultSet rs; Connection con = bridge.getConnection(); try{ sqlCommand = "Update GVclubTopic set topicViewCount=topicViewCount+"+ i +""; sqlCommand += ", topicReCount = topicReCount+"+ r +""; sqlCommand += " where topicID=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setInt(1, tID); pps.executeUpdate(); pps.close(); }catch(Exception e){ con.close(); }finally{ con.close(); } } public boolean topicInfo(int tID) throws Exception{ boolean bea = false; String sqlCommand = new String(); ResultSet rs; Connection con = bridge.getConnection(); try{ sqlCommand = "Select * From GVclubTopic where topicID=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setInt(1, tID); rs = pps.executeQuery(); if(rs.next()){ contentInfo(tID); topicID = rs.getInt(1); topicReID = rs.getInt(2); topicOrder = rs.getInt(3); topicLayer = rs.getInt(4); topicTree = rs.getInt(5); topic = rs.getString(6).trim(); userName = rs.getString(7).trim(); ccID = rs.getInt(8); ccID2 = rs.getInt(9); ccID1 = rs.getInt(10); moveCCID = rs.getInt(11); topicList = rs.getString(12); topicMood = rs.getInt(13); topicPro = rs.getInt(14); topicType = rs.getInt(15); topicTypeNum = rs.getInt(16); topicAddTime = rs.getString(17); topicAddTime = topicAddTime.replace(".000",""); topicAddip = rs.getString(18); topicLastReUser = rs.getString(19); topicLastReTime = rs.getString(20); topicViewCount = rs.getInt(21); topicReCount = rs.getInt(22); bea = true; } rs.close(); pps.close(); }catch(Exception e){ message = "系统错误,无法读取主题内容,请联系管理员"; bea = false; con.close(); }finally{ con.close(); } return bea; } public void contentInfo(int tID) throws Exception{ String sqlCommand = new String(); ResultSet rs; Connection con = bridge.getConnection(); try{ sqlCommand = "Select * From GVclubContent where topicID=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setInt(1, tID); rs = pps.executeQuery(); if(rs.next()){ content = rs.getString(3).trim(); contentUserPen = rs.getInt(4); contentUrl = rs.getInt(5); contentImg = rs.getInt(6); contentEmail = rs.getInt(7); contentCopyRight = rs.getInt(8); } rs.close(); pps.close(); }catch(Exception e){ message = "系统错误,无法读取主题内容,请联系管理员"; con.close(); }finally{ con.close(); } } public String getMessage(){ return this.message; } public String getReUsers(){ return this.reUsers; } public String getContent(){ return this.content; } public int getContentUrl(){ return this.contentUrl; } public int getContentUserPen(){ return this.contentUserPen; } public int getContentImg(){ return this.contentImg; } public int getContentEmail(){ return this.contentEmail; } public int getContentCopyRight(){ return this.contentCopyRight; } public int getTopicID(){ return this.topicID; } public int getTopicReID(){ return this.topicReID; } public String getTopic(){ return this.topic; } public int getTopicOrder(){ return this.topicOrder; } public int getTopicTree(){ return this.topicTree; } public int getTopicLayer(){ return this.topicLayer; } public String getUserName(){ return this.userName; } public int getCCID(){ return this.ccID; } public int getCCID1(){ return this.ccID1; } public int getCCID2(){ return this.ccID2; } public int getMoveCCID(){ return this.moveCCID; } public String getTopicList(){ return this.topicList; } public int getTopicMood(){ return this.topicMood; } public int getTopicPro(){ return this.topicPro; } public int getTopicType(){ return this.topicType; } public int getTopicTypeNum(){ return this.topicTypeNum; } public String getTopicAddTime(){ return this.topicAddTime; } public String getTopicAddip(){ return this.topicAddip; } public String getLastReUser(){ return this.topicLastReUser; } public String getLastReTime(){ return this.topicLastReTime; } public int getTopicViewCount(){ return this.topicViewCount; } public int getTopicReCount(){ return this.topicReCount; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -