📄 userdb.java
字号:
primaryKey = new PrimaryKey("name", PrimaryKey.TYPE_STRING);
}
public UserDb getUserDbById(int userId) {
String sql = "select name from sq_user where id=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
Conn conn = new Conn(connname);
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, userId);
rs = conn.executePreQuery();
if (rs != null && rs.next()) {
return getUser(rs.getString(1));
}
} catch (Exception e) {
logger.error("load: " + e.getMessage());
} finally {
if (conn != null) {
conn.close();
conn = null;
}
}
return null;
}
public synchronized void load() {
Conn conn = new Conn(connname);
ResultSet rs = null;
try {
PreparedStatement pstmt = conn.prepareStatement(QUERY_LOAD);
pstmt.setString(1, name);
rs = conn.executePreQuery();
if (rs != null && rs.next()) {
pwdMd5 = rs.getString(1);
question = StrUtil.getNullStr(rs.getString(2));
answer = StrUtil.getNullStr(rs.getString(3));
realName = StrUtil.getNullStr(rs.getString(4));
career = StrUtil.getNullStr(rs.getString(5));
gender = StrUtil.getNullStr(rs.getString(6));
job = StrUtil.getNullStr(rs.getString(7));
try {
birthday = DateUtil.parse(rs.getString(8));
}
catch (Exception e) {}
marriage = rs.getInt(9);
phone = StrUtil.getNullStr(rs.getString(10));
mobile = StrUtil.getNullStr(rs.getString(11));
state = StrUtil.getNullStr(rs.getString(12));
city = StrUtil.getNullStr(rs.getString(13));
address = StrUtil.getNullStr(rs.getString(14));
postCode = StrUtil.getNullStr(rs.getString(15));
IDCard = StrUtil.getNullStr(rs.getString(16));
realPic = StrUtil.getNullStr(rs.getString(17));
hobbies = StrUtil.getNullStr(rs.getString(18));
email = StrUtil.getNullStr(rs.getString(19));
oicq = StrUtil.getNullStr(rs.getString(20));
sign = StrUtil.getNullStr(rs.getString(21));
myface = StrUtil.getNullString(rs.getString(22));
myfaceWidth = rs.getInt(23);
myfaceHeight = rs.getInt(24);
experience = rs.getInt(25);
credit = rs.getInt(26);
addCount = rs.getInt(27);
delCount = rs.getInt(28);
arrestDay = rs.getInt(29);
arrestReason = StrUtil.getNullStr(rs.getString(30));
arrestTime = DateUtil.parse(rs.getString(31));
arrestPolice = StrUtil.getNullStr(rs.getString(32));
isPolice = rs.getInt(33);
try {
regDate = DateUtil.parse(rs.getString(34));
lastTime = DateUtil.parse(rs.getString(35));
curTime = DateUtil.parse(rs.getString(36));
}
catch (Exception e) {}
eliteCount = rs.getInt(37);
gold = rs.getInt(38);
favoriate = StrUtil.getNullString(rs.getString(39));
valid = rs.getInt(40)==1?true:false;
rawPwd = rs.getString(41);
diskSpaceAllowed = rs.getInt(42);
diskSpaceUsed = rs.getInt(43);
secret = rs.getInt(44)==1?true:false;
id = rs.getLong(45);
ip = StrUtil.getNullStr(rs.getString(46));
releaseTime = DateUtil.parse(rs.getString(47));
String tzID = StrUtil.getNullStr(rs.getString(48));
timeZone = TimeZone.getTimeZone(tzID);
home = StrUtil.getNullStr(rs.getString(49));
msn = StrUtil.getNullStr(rs.getString(50));
groupCode = StrUtil.getNullStr(rs.getString(51));
locale = StrUtil.getNullStr(rs.getString(52));
loaded = true;
primaryKey.setValue(name);
}
} catch (Exception e) {
logger.error("load: " + e.getMessage());
} finally {
if (conn != null) {
conn.close();
conn = null;
}
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getExperience() {
return this.experience;
}
public void setExperience(int e) {
this.experience = e;
}
public int getCredit() {
return this.credit;
}
public void setCredit(int c) {
this.credit = c;
}
public int getAddCount() {
return addCount;
}
public void setAddCount(int a) {
this.addCount = a;
}
public int getDelCount() {
return delCount;
}
public void setDelCount(int d) {
this.delCount = d;
}
public String getPwdMd5() {
return pwdMd5;
}
public void setPwdMd5(String p) {
this.pwdMd5 = p;
}
public String getRealName() {
return realName;
}
public String getEmail() {
return email;
}
public String getGender() {
return gender;
}
public Date getRegDate() {
return regDate;
}
public String getSign() {
return sign;
}
public String getMyface() {
return myface;
}
public int getMyfaceWidth() {
return myfaceWidth;
}
public void setRealName(String r) {
realName = r;
}
public void setEmail(String e) {
email = e;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
public void setSign(String sign) {
this.sign = sign;
}
public int getMyfaceHeight() {
return this.myfaceHeight;
}
public String getQuestion() {
return question;
}
public String getAnswer() {
return answer;
}
public String getJob() {
return job;
}
public String getPhone() {
return phone;
}
public Date getBirthday() {
return birthday;
}
public String getMobile() {
return mobile;
}
public String getState() {
return state;
}
public String getAddress() {
return address;
}
public String getOicq() {
return oicq;
}
public String getPostCode() {
return postCode;
}
public String getHobbies() {
return hobbies;
}
public String getCity() {
return city;
}
public boolean isLoaded() {
return loaded;
}
public String getIDCard() {
return IDCard;
}
public int getLevel() {
int level = 1;
if (credit < 1000) {
level = 1;
} else if (credit >= 1000 && credit < 2000) {
level = 2;
} else if (credit >= 2000 && credit < 3000) {
level = 3;
} else if (credit >= 3000 && credit < 4000) {
level = 4;
} else if (credit >= 4000 && credit < 5000) {
level = 5;
} else if (credit >= 5000 && credit < 6000) {
level = 6;
} else if (credit >= 6000 && credit < 7000) {
level = 7;
} else {
level = 8;
}
return level;
}
/**
* 取得等级的描述
* @return String
*/
public String getLevelDesc() {
// String leveldesc[] = {"初入江湖", "小有名气", "名动一方", "天下闻名", "一代宗师", "超凡入圣",
// "天外飞仙", "无所不能"};
// String levelDesc = leveldesc[getLevel()-1];
// return levelDesc;
UserLevelDb uld = new UserLevelDb();
Vector v = uld.getAllLevel();
if (credit<0)
credit = 0;
int i = 0;
int len = v.size();
while (i<len) {
uld = (UserLevelDb)v.get(i);
int lv = uld.getLevel();
if ((i+1)<len) {
UserLevelDb uld1 = (UserLevelDb)v.get(i+1);
int lv1 = uld1.getLevel();
if (credit>=lv && credit<lv1)
return uld.getDesc();
}
else
return uld.getDesc();
i++;
}
return "";
}
public void setMyfaceHeight(int h) {
this.myfaceHeight = h;
}
public void setMyface(String myface) {
this.myface = myface;
}
public void setMyfaceWidth(int myfaceWidth) {
this.myfaceWidth = myfaceWidth;
}
public void setQuestion(String question) {
this.question = question;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public void setJob(String job) {
this.job = job;
}
public void setPhone(String phone) {
this.phone = phone;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -