📄 clubtopicmanage.java
字号:
/* * ClubTopicManage.java * Created on 2005年1月5日, 下午3:49 */package com.gamvan.club.topic;import com.gamvan.conn.*;import com.gamvan.tools.*;import com.gamvan.club.ClubUsers;import com.gamvan.club.ClubClassInfo;import com.gamvan.club.topic.ClubTopicInfo;//import com.gamvan.club.ClubCounter;import java.sql.*;import java.util.*;public class ClubTopicManage { private String act = new String(); private int topicID, topicPro, moveCCID, ccID, topicOrder; private double userMark=0, userMoney=0, userCredit=0; private String message = new String(); private String userName, byUser, saveLink; 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 topicManage(String act, int tID) throws Exception{ boolean bea = false; bea = cti.topicInfo(tID); topicPro = cti.getTopicPro(); if(bea && topicPro!=4){ if(act.equals("del")){ bea = topicInfoUpdate(tID, 4, 0); if(bea){ userName = cti.getUserName(); message = cti.getTopic() + "<br /><br />主题删除操作成功!<br />"; if(cti.getTopicLayer()==0){ //判断所要操作的帖子是主题还是回复 cu.userUpdate(userName, userMark, userMoney, userCredit, 0, -1); //ccu.counterUpdate(0, 0, -1, 0, 0, 0, 0, ""); }else{ cu.userUpdate(userName, userMark, userMoney, userCredit, 1, -1); //ccu.counterUpdate(0, 0, 0, -1, 0, 0, 0, ""); } }else{ message= "主题删除操作失败!"; } }else if(act.equals("best")){ if(topicPro!=1){ bea = topicInfoUpdate(tID, 1,0); if(bea){ userName = cti.getUserName(); message = cti.getTopic() + "<br /><br />主题已被加为精品!<br />"; cu.userUpdate(userName, userMark, userMoney, userCredit, 3, 0); }else{ message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!"; } }else{ message = cti.getTopic() + "<br /><br />主题已经是精品文章,请不要重复操作!<br />"; } }else if(act.equals("nobest")){ if(topicPro==1){ bea = topicInfoUpdate(tID,0,0); if(bea){ userName = cti.getUserName(); message = cti.getTopic() + "<br /><br />文章精品属性已被取消!<br />"; cu.userUpdate(userName, userMark, userMoney, userCredit, 3, 0); }else{ message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!"; } }else{ message = cti.getTopic() + "<br /><br />该主题属性已经不是精品,请不要重复操作!<br />"; } }else if(act.equals("move")){ bea = topicMove(tID,moveCCID); if(bea){ userName = cti.getUserName(); cu.userUpdate(userName, userMark, userMoney, userCredit, 3, 0); }else{ message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!"; } }else if(act.equals("top")){ bea = topicInfoUpdate(tID, topicOrder, 1); if(bea){ //bea = topicMove(tID,moveCCID); userName = cti.getUserName(); cu.userUpdate(userName, userMark, userMoney, userCredit, 3, 0); message = cti.getTopic() + "<br /><br />置顶操作成功!<br />"; }else{ message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!"; } } }else{ message= "您所请求的操作的文章不存在!"; } return bea; } public boolean topicMove(int tID, int moveID){ boolean bea = false; int ccidd; int ccid1=0, ccid2=0; int ccidd1=0, ccidd2=0; ClubClassInfo cci = new ClubClassInfo(); cci.classInfo(moveID); ccidd = cci.getIDD(); if(ccidd>0){ cci.classInfo(ccidd); ccid1 = ccidd; ccidd1 = cci.getIDD(); if(ccidd1>0){ ccid2 = ccidd1; } } try{ String sqlCommand = new String(); Connection con = bridge.getConnection(); 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; } 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 setSaveLink(String saveLink){ this.saveLink = saveLink; } public void setByUser(String byUser){ this.byUser = byUser; } 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 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; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -