📄 clubtopicpost.java
字号:
package com.gamvan.club.topic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.gamvan.club.ClubClassInfo;
import com.gamvan.club.ClubCounter;
import com.gamvan.club.ClubUsers;
import com.gamvan.conn.ConnClub;
import com.gamvan.tools.ArrayEdit;
import com.gamvan.tools.EncodeString;
import com.gamvan.tools.Gb;
//import java.util.Date
/* Made in GamVan
* 社区发帖处理
*/
public class ClubTopicPost{
private String message;
private String userName, userPass, userPass2;
private int topicID=0, topicReID=0,topicReID2=0, topicLen=0;
private String topicAddip;
private String topic, content="";
private int contentUserPen, contentUrl, contentImg, contentEmail, contentCopyRight;
private String contentEditInfo; //编辑信息。
private String contentReUser; //回复过主题的用户
private String topicColor, topicBold ;
private int topicType, topicMood, topicPro;//topicPro 锁定、禁止回复、精品。
private int ccID, ccID1, ccID2, moveCCID; //所在分类,moveCCID移动自某分类。
private int topicTypeUserInfo; //购买、积分、求助特殊类型的主题关联的用户积分,金币得失情况
private int topicTypeInfo; //购买、积分、求助特殊类型的主题日志发生时该主题的类型
private double topicTypeNum; //特殊类型主题关联的积分或金币
private String topicTypeUsers; //购买、积分、求助特殊类型的主题关联的用户
private int topicTree=0, topicLayer=0, topicOrder=0; //topicOrder主题排序,可固定,回复树形排序
private int topicReCount = 0; //主题回复次数
private int userID = 0;
private String act; //判断是编辑、添加、修过或是删除
private double userMark, userCredit, userMoney;
private String topicReUsers = new String("");
//格式化当前时间
java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private String now = isNow.format(new java.util.Date());
ClubCounter ccu = new ClubCounter();//社区统计
ClubClassInfo cci = new ClubClassInfo();//社区主题、回复统计
ConnClub bridge = new ConnClub(); //数据库链接
EncodeString ens = new EncodeString(); //字符串加密/转换
ArrayEdit ae = new ArrayEdit(); //字符串数组处理
Gb clubgb = new Gb(); //中文编码处理
ClubTopicInfo cti = new ClubTopicInfo();
int cLeg = 0; //内容长度
int tLeg = 0; //主题长度
public boolean topicPost(int ccID2, int ccID1) throws Exception{
boolean bea = false;
boolean tempbea = false;
tempbea = userLogin();
ClubUsers cu = new ClubUsers();
if(this.topic!=null){
tLeg = this.topic.length();
}else{
tLeg = 0;
}
if(this.content!=null){
cLeg = this.content.length();
}else{
cLeg = 0;
}
if(tempbea){
if(tLeg>80 || cLeg>8000){
message = "系统错误,主题不能超过80字符,内容最多不能超过8000字符!";
message +="<br />当前主题: " + tLeg +" 个字符";
message +="<br />当前内容: " + cLeg +" 个字符";
}else{
if(act.equals("add")){
cci.classCounter(ccID, 1, 0); //社区主题、回复统计
cu.userUpdate(userID,1,0,1); //更新社区制度信息
bea = topicAdd();
}else if(act.equals("re")){
cci.classCounter(ccID, 0, 1); //社区主题、回复统计
cu.userUpdate(userID,2,1,1); //更新社区制度信息
bea = topicRe();
Connection con = bridge.getConnection();
try{
String sqlCommand = new String();
sqlCommand = "Update GVclubTopic set topicReID=? where topicID=?";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setInt(1, topicID);
pps.setInt(2, topicReID2); //回复的主题
pps.executeUpdate();
pps.close();
updateReMyLike(topicReID2); //订阅的主题更新最后回复时间
}catch(Exception e){
con.close();
}finally{
con.close();
}
}else if(act.equals("edit")){
cu.userUpdate(userID,2,3,0); //更新社区制度信息
bea = topicEdit();
}
}
}else{
bea = false;
}
if(!bea){
if(message==null || message.equals("")){
message = "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!";
}
}
return bea;
}
//====================================================
// 更新回复主题被订阅的最后时间。
public boolean updateReMyLike(int topicid) throws Exception{
boolean bea = false;
Connection con = bridge.getConnection();
String sqlCommand = new String();
if(topicid>0){
try{
sqlCommand = "Update GVclubTopicIlike set";
sqlCommand += " topicLastReTime=? 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 void editReUsers(int tID, int reID) throws Exception{
boolean bea = false;
String sqlCommand = new String();
boolean bea1 = false;
Connection con = bridge.getConnection();//数据库链接
try{
if(tID>0){
if(isReUsers(tID)){
if(!ae.txtsArray(topicReUsers, userName, "|")){
sqlCommand = "Update GVclubTopicReUsers set reUsers=? where topicID=?";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setString(1, topicReUsers + "|" + userName);
pps.setInt(2, tID);
pps.executeUpdate();
pps.close();
}
}else{
sqlCommand = "Insert into GVclubTopicReUsers(reUsers, topicID)";
sqlCommand += " Values(?,?)";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setString(1, userName);
pps.setInt(2, tID);
pps.executeUpdate();
pps.close();
}
}
if(reID>0){
if(isReUsers(reID)){
if(!ae.txtsArray(topicReUsers, userName, "|")){
sqlCommand = "Update GVclubTopicReUsers set reUsers=? where topicID=?";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setString(1, topicReUsers + "|" + userName);
pps.setInt(2, reID);
pps.executeUpdate();
pps.close();
}
}else{
sqlCommand = "Insert into GVclubTopicReUsers(reUsers, topicID)";
sqlCommand += " Values(?,?)";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setString(1, userName);
pps.setInt(2, reID);
pps.executeUpdate();
pps.close();
}
}
}catch(Exception e){
con.close();
}finally{
con.close();
}
}
//判断是否已经记录回复人员名单
public boolean isReUsers(int id){
boolean bea = false;
try{
if(cti.selectReUsers(id)){
topicReUsers = cti.getReUsers();
bea = true;
}else{
bea = false;
}
}catch(Exception e){
}
return bea;
}
public boolean topicEdit() throws Exception{
boolean bea = false;
String sqlCommand = new String();
Connection con = bridge.getConnection();//数据库链接
try{
sqlCommand = "Update GVclubTopic set topic=?, topicMood=?, topicList=?";
sqlCommand += ", topicType=?, topicTypeNum=?, topicLen=? where topicID=?";
PreparedStatement pps = con.prepareStatement(sqlCommand);
pps.setString(1,topic);
pps.setInt(2,topicMood);
pps.setString(3, topicColor + "|" + topicBold);
pps.setInt(4, topicType);
pps.setDouble(5, topicTypeNum);
pps.setInt(6, content.length());
pps.setInt(7, topicID);
pps.executeUpdate();
pps.close();
sqlCommand="";
sqlCommand = "Update GVclubContent set content=?, contentUserPen=?, contentUrl=?, contentImg=?";
sqlCommand += ",contentEmail=?, contentCopyRight=? where topicID=?";
PreparedStatement pps1 = con.prepareStatement(sqlCommand);
pps1.setString(1,content);
pps1.setInt(2,contentUserPen);
pps1.setInt(3,contentUrl);
pps1.setInt(4,contentImg);
pps1.setInt(5,contentEmail);
pps1.setInt(6,contentCopyRight);
pps1.setInt(7,topicID);
pps1.executeUpdate();
pps1.close();
con.close();
bea = true;
message = sqlCommand + content;
}catch(Exception e){
bea = false;
message = "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!";
con.close();
}finally{
con.close();
}
return bea;
}
private void topicReUpdate(int id) throws Exception{//更新回复排序
String sqlCommand = new String();
Connection con = bridge.getConnection();
try{
sqlCommand = "Update GVclubTopic set topicOrder=topicOrder+1 ";
if(topicReID==0){
sqlCommand += " where topicReID="+ id +" and topicLayer<>0";
}else{
sqlCommand += " where topicReID="+ id +" and topicLayer<>0 and topicOrder > "+ topicOrder +"";
}
PreparedStatement pps2 = con.prepareStatement(sqlCommand);
pps2.executeUpdate();
pps2.close();
}catch(Exception e){
message = "系统出现意外错误,请重新尝试,如果不成功请联系在线勤杂工!";
con.close();
}finally{
con.close();
}
}
private boolean topicRe() throws Exception{
boolean bea = false;
editReUsers(topicID, topicReID);
int tTree = 0;
topicReID2=topicID; //被回复的主题标题。
if(topicReID==0){ //如果回复的是主题
cti.topicInfo(topicID); //取主题信息
}else{
cti.topicInfo(topicReID); //取回复信息
}
topicOrder = cti.getTopicOrder();
topicLayer = cti.getTopicLayer();
topicTree = cti.getTopicTree();
topicReCount = cti.getTopicReCount();
if(topicReID==0){
topicReUpdate(topicID); //更新回复排序
topicOrder=1;
cti.topicUpdate(topicID,0,1); //更新主题回复次数
}else{
topicReUpdate(topicReID2); //更新回复排序
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -