userprivdb.java~24~
来自「云网论坛CWBBS 源码,内容丰富,学习,参考,教学的好资料,具体见内说明,」· JAVA~24~ 代码 · 共 84 行
JAVA~24~
84 行
package com.redmoon.forum.person;
import com.cloudwebsoft.framework.base.*;
import com.redmoon.forum.Config;
import com.cloudwebsoft.framework.db.JdbcTemplate;
import cn.js.fan.util.DateUtil;
import java.util.Date;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class UserPrivDb extends QObjectDb {
public static String querySave;
public UserPrivDb() {
}
public boolean init(String userName) {
Config cfg = new Config();
// 发表贴子 回复贴子
String priv = "11";
String strAttachDayCount = cfg.getProperty("forum.maxAttachDayCount");
int maxAttachDayCount = Integer.parseInt(strAttachDayCount);
String strMaxAttachmentSize = cfg.getProperty("forum.maxAttachmentSize");
int maxAttachmentSize = Integer.parseInt(strMaxAttachmentSize);
String attach_upload = cfg.getProperty("forum.canUserUploadAttach").
equals("true") ? "1" : "0";
String attach_download = cfg.getProperty("forum.canUserDownloadAttach").
equals("true") ? "1" : "0";
String add_topic = cfg.getProperty("forum.canUserAddTopic").equals(
"true") ? "1" : "0";
String reply_topic = cfg.getProperty("forum.canUserReplyTopic").equals(
"true") ? "1" : "0";
String vote = cfg.getProperty("forum.canUserVote").equals("true") ? "1" :
"0";
return create(new JdbcTemplate(), new Object[] {
userName, priv, new Integer(maxAttachDayCount),
new Integer(maxAttachmentSize), attach_upload,
attach_download,add_topic,reply_topic,vote
});
}
public UserPrivDb getUserPrivDb(String userName) {
UserPrivDb up = (UserPrivDb)getQObjectDb(userName);
if (up==null) {
init(userName);
return (UserPrivDb)getQObjectDb(userName);
}
else
return up;
}
public int getAttachTodayUploadCount() {
String sToday = resultRecord.getString("attach_today");
if (sToday==null)
return 0;
Date d = DateUtil.parse(sToday);
if (DateUtil.isSameDay(d, new java.util.Date()))
return resultRecord.getInt("attach_today_upload_count");
// 如果记录的日期与今日不是同一天
resultRecord.set("attach_today", "" + new java.util.Date().getTime());
resultRecord.set("attach_today_upload_count", new Integer(0));
save();
return 0;
}
public boolean addAttachTodayUploadCount() {
resultRecord.set("attach_today_upload_count", new Integer(resultRecord.getInt("attach_today_upload_count") + 1));
return save();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?