📄 user.java
字号:
package com.bcxy.bbs.forum;
/**
* Title:
* Description:
* Copyright:
* Company: www.liyunet.com
*
* @author lishujiang
* @version 1.0
*/
import org.apache.log4j.Logger;
import com.bcxy.bbs.filter.MyFilter;
import com.bcxy.bbs.util.BBSConst;
import com.bcxy.db.JdbcWrapper;
import com.bcxy.util.DateUtil;
import com.bcxy.util.StringUtil;
public class User {
private Logger log = Logger.getLogger(User.class);
private String username, password, lastlogin;
private int userID, article, logins, width, height, bbsType, lockUser,
userClass, userWealth, userEP, userCP;
private String userName, userEmail, userPassword, sign, sex, homePage,
addDate;
private String face, oicq, lastLogin, userGroup, title, showRE, reann;
String errMSG = "";
public User() {
}
public void setUserID(int userID) {
this.userID = userID;
}
public int getUserID() {
return this.userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return this.userName;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public String getUserEmail() {
return this.userEmail;
}
public void setArticle(int article) {
this.article = article;
}
public int getArticle() {
return this.article;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserPassword() {
return this.userPassword;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getNoFilterSign() {
return this.sign;
}
public String getSign() {
return (new MyFilter(StringUtil.replace(StringUtil
.convertNewlines(StringUtil.escapeHTMLTags(this.sign)), " ",
" "))).getFilterString();
}
public void setSex(String sex) {
this.sex = sex;
}
public String getSex() {
return this.sex;
}
public void setHomePage(String homePage) {
this.homePage = homePage;
}
public String getHomePage() {
return this.homePage;
}
public void setAddDate(String addDate) {
this.addDate = addDate;
}
public String getAddDate() {
return this.addDate;
}
public void setLogins(int logins) {
this.logins = logins;
}
public int getLogins() {
return this.logins;
}
public void setFace(String face) {
this.face = face;
}
public String getFace() {
return this.face;
}
public void setWidth(int width) {
this.width = width;
}
public int getWidth() {
return this.width;
}
public void setHeight(int height) {
this.height = height;
}
public int getHeight() {
return this.height;
}
public void setOicq(String oicq) {
this.oicq = oicq;
}
public String getOicq() {
return this.oicq;
}
public void setLastLogin(String lastLogin) {
this.lastLogin = lastLogin;
}
public String getLastLogin() {
return this.lastLogin;
}
public void setBbsType(int bbsType) {
this.bbsType = bbsType;
}
public int getBbsType() {
return this.bbsType;
}
public void setLockUser(int lockUser) {
this.lockUser = lockUser;
}
public int getLockUser() {
return this.lockUser;
}
public void setUserClass(int userClass) {
this.userClass = userClass;
}
public int getUserClass() {
return this.userClass;
}
public void setUserGroup(String userGroup) {
this.userGroup = userGroup;
}
public String getUserGroup() {
return this.userGroup;
}
public void setUserWealth(int userWealth) {
this.userWealth = userWealth;
}
public int getUserWealth() {
return this.userWealth;
}
public void setUserEP(int userEP) {
this.userEP = userEP;
}
public int getUserEP() {
return this.userEP;
}
public void setUserCP(int userCP) {
this.userCP = userCP;
}
public int getUserCP() {
return this.userCP;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
public void setReann(String reann) {
this.reann = reann;
}
public String getReann() {
return this.reann;
}
public User(String userName, String userPassword, int loginSign)
throws UserNotFoundException, Exception {
boolean foundErr = false;
if ("".equals(userName)) {
errMSG = errMSG + "请输入您的用户名。";
foundErr = true;
}
if ("".equals(userPassword)) {
errMSG = errMSG + "请输入您的密码。";
foundErr = true;
}
if (foundErr) {
throw new Exception(errMSG);
}
this.userName = userName;
this.userPassword = userPassword;
if (loginSign > 0)
checkUser(loginSign);
}
public void checkUser(int loginSign) throws UserNotFoundException,
Exception {
JdbcWrapper jw = new JdbcWrapper();
try {
jw.executeQuery("select * from " + BBSConst.TABLE_USER
+ " where UserName='" + userName + "' and UserPassword='"
+ userPassword + "'");
if (jw.next()) {
if (loginSign == 4) {
this.setUserClass(jw.getInt("userclass"));
this.setLastLogin(jw.getString("lastlogin"));
return;
}
// use the resultset to define the varible used!
lastLogin = jw.getString("lastlogin");
article = jw.getInt("Article");
userClass = jw.getInt("userclass");
if (userClass < 18) {
if (article < SkinUtil.getPoint(2)) {
userClass = 1;
}
for (int i = 2; i < 17; i++) {
if (article >= SkinUtil.getPoint(i)
&& article < SkinUtil.getPoint(i + 1)) {
userClass = i;
}
}
if (article >= SkinUtil.getPoint(17)) {
userClass = 17;
}
}
String theNow = DateUtil.getLocalDate();
this.lastLogin = jw.getString("lastlogin");
jw.clearParameters();
String sql = "";
int wealthLogin = Integer.parseInt(ForumPropertiesManager
.getString("wealthLogin"));
int epLogin = Integer.parseInt(ForumPropertiesManager
.getString("epLogin"));
int cpLogin = Integer.parseInt(ForumPropertiesManager
.getString("cpLogin"));
int wealthAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("wealthAnnounce"));
int wealthReAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("wealthReannounce"));
int epAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("epAnnounce"));
int epReAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("epReannounce"));
int cpAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("cpAnnounce"));
int cpReAnnounce = Integer.parseInt(ForumPropertiesManager
.getString("cpReannounce"));
//
switch (loginSign) {
case 1:
sql = "update " + BBSConst.TABLE_USER
+ " set userWealth=userWealth+" + wealthLogin
+ ",userEP=userEP+" + epLogin + ",userCP=userCP+"
+ cpLogin + ",userClass=" + userClass
+ ",lastlogin='" + theNow
+ "',logins=logins+1 where username=?";
break;
case 2:
sql = "update " + BBSConst.TABLE_USER
+ " set article=article+1,userWealth=userWealth+"
+ wealthAnnounce + ",userEP=userEP+" + epAnnounce
+ ",userCP=userCP+" + cpAnnounce + ",userclass="
// + userClass + ",lastlogin=Now() where
// username=?";
+ userClass + " where username=?";
break;
case 3:
sql = "update " + BBSConst.TABLE_USER
+ " set article=article+1,userWealth=userWealth+"
+ wealthReAnnounce + ",userEP=userEP+"
+ epReAnnounce + ",userCP=userCP+" + cpReAnnounce
+ ",userclass=" + userClass
// + ",lastlogin=Now() where username=?";
+ " where username=?";
break;
default:
sql = "update " + BBSConst.TABLE_USER
+ " set userWealth=userWealth+" + wealthLogin
+ ",userEP=userEP+" + epLogin + ",userCP=userCP+"
+ cpLogin + ",userClass=" + userClass
+ ",lastlogin='" + theNow
+ "',logins=logins+1 where username=?";
break;
}
jw.prepareStatement(sql);
jw.setString(1, userName);
jw.executeUpdate();
} else {
throw new UserNotFoundException("对不起此用户不存在请检查你的密码与用户名");
}
} catch (UserNotFoundException e) {
log.error("该用户不存在", e);
throw e;
} catch (Exception e) {
log.error("检查用户状态出错", e);
throw e;
} finally {
jw.close();
}
}
public String getUserClassStr() {
String tempStr = "";
switch (this.getUserClass()) {
case 1:
tempStr = " <img src=pic/level0.gif>";
break;
case 2:
tempStr = " <img src=pic/level1.gif>";
break;
case 3:
tempStr = " <img src=pic/level2.gif>";
break;
case 5:
tempStr = " <img src=pic/level3.gif>";
break;
case 6:
tempStr = " <img src=pic/level4.gif>";
break;
case 7:
tempStr = " <img src=pic/level5.gif>";
break;
case 8:
tempStr = " <img src=pic/level6.gif>";
break;
case 9:
tempStr = " <img src=pic/level7.gif>";
break;
case 10:
tempStr = " <img src=pic/level8.gif>";
break;
case 11:
tempStr = " <img src=pic/level9.gif>";
break;
case 12:
tempStr = " <img src=pic/level9.gif>";
break;
case 13:
tempStr = " <img src=pic/level9.gif>";
break;
case 14:
tempStr = " <img src=pic/level9.gif>";
break;
case 15:
tempStr = " <img src=pic/level9.gif>";
break;
case 16:
tempStr = " <img src=pic/level9.gif>";
break;
case 17:
tempStr = " <img src=pic/level9.gif>";
break;
case 18:
tempStr = " <img src=pic/level9.gif>";
break;
case 19:
tempStr = " <img src=pic/level10.gif>";
break;
case 20:
tempStr = " <img src=pic/level10.gif>";
break;
}
return tempStr;
}
public String getErrMSG() {
return errMSG;
}
public void setErrMSG(String errMSG) {
this.errMSG = errMSG;
}
public String getLastlogin() {
return lastlogin;
}
public void setLastlogin(String lastlogin) {
this.lastlogin = lastlogin;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getShowRE() {
return showRE;
}
public void setShowRE(String showRE) {
this.showRE = showRE;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -