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

📄 clubtopiclog.java

📁 GamVan Club v1.1 源代码
💻 JAVA
字号:
/*
 * Created on 2005-5-28
 * Made In GamVan.com
 * 社区主题管理员操作日志,加(减)积分、信誉、金币
 */
package com.gamvan.club.topic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.gamvan.conn.ConnClub;
public class ClubTopicLog {
	private int userID=0, topicID=0, topicLogID=0;
	private double userCredit=0, userMoney=0, userMark=0; //用户信誉、金币、积分变量
	private int topicLogByUserID=0; //操作人员ID
	private String userName = "";
	private String topic = ""; //主题内容
	private String topicLogTxt = ""; //日志备注,日志产生原因
	private String topicLogSo = ""; //日志结果,日志产生的内容
	private String topicLogByUserName = ""; //操作人员
	private String topicLogByUserIP = "" ;//操作人员IP
	private String topicLogByDateTime = ""; //操作时间
	private String message = ""; //收集信息
	private int topicLogList = 0, topicLogByUserList=0; //日志信息是否显示在网页底部
    // 格式化当前时间
    java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String now = isNow.format(new java.util.Date());
	ConnClub bridge = new ConnClub();
    
	
	// 执行日志记录
	public boolean executeLog() throws Exception{
		boolean bea = false;
		if(topicID<0){
			message = "log is error";
			return false;
		}
		
		try{
			if(selectLogTU(topicID, topicLogByUserID)){
				bea = updateLog();
			}else{
				bea = insertLog();
			}
		}catch(Exception e){
			message = e.toString();
		}		
		return bea;
	}
	
	
	// 更新日志相关信息
	public boolean updateLog() throws SQLException{
		boolean bea =false;
		Connection con = bridge.getConnection();
		StringBuffer sqlCommand = new StringBuffer("");
		try{
			sqlCommand.append("Update GVclubTopicLog set topic=?, topicLogTxt=?");
			sqlCommand.append(", topicLogByUserIP=?, topicLogByDateTime=?");
			sqlCommand.append(", userCredit=?, userMark=?, userMoney=?");
			sqlCommand.append(", topicLogSo=?, topicLogByUserList=? where topicLogID=?");
			PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
    		pps.setString(1,topic);
    		pps.setString(2,topicLogTxt);
    		pps.setInt(3,topicLogByUserID);
    		pps.setString(4,now);
    		pps.setDouble(5,userCredit);
    		pps.setDouble(6,userMark);
    		pps.setDouble(7,userMoney);
    		pps.setString(8,topicLogSo);
    		pps.setInt(9,topicLogByUserList);
			pps.setInt(10,topicLogID);
			pps.executeUpdate();
			pps.close();
			bea = true;
			message = "日志记录成功!";
		}catch(Exception e){
			message = "更新日志出错\n" + e.toString();
			bea = false;
		}finally{
			con.close();
		}		
		return bea;
	}
	
	//查找日志根据帖子ID,和操作用户ID,只判断属于自己的日志是否存在。
	public boolean selectLogTU(int tid, int uid) throws SQLException{
		boolean bea = false;
		Connection con = bridge.getConnection();
		StringBuffer sqlCommand = new StringBuffer("");
		ResultSet rs;
		try{
			sqlCommand.append("Select * From GVclubTopicLog where ");
			sqlCommand.append(" topicID=? and topicLogByUserID=?");
			sqlCommand.append(" and topicLogSo=?");
			PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
			pps.setInt(1,topicID);
			pps.setInt(2,topicLogByUserID);
			pps.setString(3,topicLogSo);
			rs = pps.executeQuery();
			if(rs.next()){
				topicLogID = rs.getInt(1);
				bea = true;
			}else{
				bea = false;
			}
			rs.close();
			pps.close();
		}catch(Exception e){
			message = e.toString();
			bea = false;
		}finally{
			con.close();
		}
		
		return bea;		
	}
	//添加日志
    public boolean insertLog() throws SQLException{
    	boolean bea = false;
    	Connection con = bridge.getConnection();
    	StringBuffer sqlCommand = new StringBuffer("");
    	try{
    		sqlCommand.append("insert into GVclubTopicLog(");
    		sqlCommand.append("userID, userName, topic, topicID,");
    		sqlCommand.append("topicLogTxt,topicLogByUserID, topicLogByUserName,");
    		sqlCommand.append("topicLogByUserIP, topicLogByDateTime,");
    		sqlCommand.append("userCredit,userMark, userMoney, topicLogSo,");
    		sqlCommand.append("topicLogByUserList, topicLogList");
    		sqlCommand.append(") values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    		PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
    		pps.setInt(1,userID);
    		pps.setString(2,userName);
    		pps.setString(3,topic);
    		pps.setInt(4,topicID);
    		pps.setString(5,topicLogTxt);
    		pps.setInt(6,topicLogByUserID);
    		pps.setString(7,topicLogByUserName);
    		pps.setString(8,topicLogByUserIP);
    		pps.setString(9,now);
    		pps.setDouble(10,userCredit);
    		pps.setDouble(11,userMark);
    		pps.setDouble(12,userMoney);
    		pps.setString(13,topicLogSo);
    		pps.setInt(14,topicLogByUserList);
    		pps.setInt(15,topicLogList);
    		pps.executeUpdate();
    		pps.close();
    		bea = true;
    		message = "本次操作已被记录";
    	}catch(Exception e){
    		message = e.toString();
    		bea = false;
    	}finally{
    		con.close();
    	}
		
    	return bea;
    }
    //定义方法
    public String getMessage(){
    	return this.message;
    }
    
    public void setUserMark(double userMark){
    	this.userMark = userMark;
    }
    public void setUserMark(String userMark){
    	if(userMark!=null){
    		this.userMark = Double.parseDouble(userMark);
    	}else{
    		this.userMark = 0;
    	}
    }
    public void setUserMoney(double userMoney){
    	this.userMoney = userMoney;
    }
    public void setUserMoney(String userMoney){
    	if(userMoney!=null){
    		this.userMoney = Double.parseDouble(userMoney);
    	}else{
    		this.userMoney = 0;
    	}
    }
    public void setUserCredit(double userCredit){
		this.userCredit = userCredit;
	}
    public void setUserCredit(String userCredit){
    	if(userCredit!=null){
    		this.userCredit = Double.parseDouble(userCredit);
    	}else{
    		this.userCredit = 0;
    	}
	} 
    
	public void setTopicID(int topicID){
		this.topicID = topicID;
	}
    public void setTopic(String s){
    	this.topic = s;
    }
    public void setTopicLogSo(String s){
    	this.topicLogSo = s;
    }
    public void setTopicLogTxt(String s){
    	this.topicLogTxt = s;
    }
	public void setTopicLogByUserID(int byUserID){
		this.topicLogByUserID = byUserID;
	}
	public void setTopicLogByUserName(String byUserName){
		this.topicLogByUserName = byUserName;
	}
	public void setTopicLogByUserIP(String byUserIP){
		this.topicLogByUserIP = byUserIP;
	}
	
	public void setUserID(int userID){
		this.userID = userID;
	}
	public void setUserName(String userName){
		this.userName = userName;
	}
	public void setTopicLogByUserList(int topicLogByUserList){
		this.topicLogByUserList = topicLogByUserList;
	}
	public void setTopicLogList(int topicLogList){
		this.topicLogList = topicLogList;
	}
	public void setTopicLogByUserList(String topicLogByUserList){
		if(topicLogByUserList!=null){
			this.topicLogByUserList = Integer.parseInt(topicLogByUserList);
		}else{
			this.topicLogByUserList = 0;
		}
	}
	public void setTopicLogList(String  topicLogList){
		if(topicLogList!=null){
			this.topicLogList = Integer.parseInt(topicLogList);
		}else{
			this.topicLogList = 0;
		}
	}
}

⌨️ 快捷键说明

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