📄 bbsdoc.java
字号:
package com.easyjf.bbs.business;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import com.easyjf.dbo.EasyJDB;
import com.easyjf.dbo.IObject;
import com.easyjf.util.CommUtil;
/**
* BBS文档信息-通过实现IObject接口支持EasyDBO零配置文件方式映射
* @author 蔡世友
*
*/
public class BBSDoc implements IObject{
// Fields
private String cid;
private String dirSn;
private String dirPath;
private String parentId;
private String title;
private String content;
private String intro;
private String files;
private String imgs;
private Integer readTimes;
private String tagPic;
private Integer voteScore;
private Integer score;
private String vrtype;//user会员能看,score积分限制,reply回复能看,member开源团队正式成员能看,admin团队管理人员能看
private String vrvalue;//当vrtype为score的时候
private String inputUser;
private Date inputTime;
private Date modifyTime;
private String ip;
private String clientInfo;
private Integer good;
private Integer bad;
private String source;
private Integer topMessage;
private Integer eliteMessage;
private Integer status; //小于0则表示已经锁定(-1)或屏蔽(-2),不准看
private String lastUpdateUser;
private Date lastUpdateTime;
private Integer replyNum;
public static final String[][] vRTypeTitle={{"","公开"},{"user","会员可见"},{"score","积分限制"},{"reply","回复可见"},{"member","EasyJF成员可见"},{"admin","EasyJF决策系统成员"}};
//Constructors
public BBSDoc()
{
}
public BBSDoc(String cid)
{
this.cid=cid;
}
// 类的方法
public boolean isTop()
{
return (topMessage!=null && topMessage.intValue()==1);
}
public boolean isElite()
{
return (eliteMessage!=null && eliteMessage.intValue()==1);
}
public boolean isHot()
{
return (readTimes!=null && readTimes.intValue()>500);
}
public boolean isLock()
{
return false;
}
public List children() {
return query("parentId='"+this.cid+"'");
}
public Number replyNum()
{
EasyJDB db=EasyJDB.getInstance();
Number num=(Number)db.uniqueResult("select count(*) from BBSDoc where parentId='"+this.cid+"' and status>=0");
return num;
}
public static BBSDoc read(String cid)
{
EasyJDB db=EasyJDB.getInstance();
return (BBSDoc)db.get(BBSDoc.class,cid);
}
public boolean save()
{
EasyJDB db=EasyJDB.getInstance();
return db.saveOrUpdate(this);
}
public boolean update()
{
EasyJDB db=EasyJDB.getInstance();
return db.update(this);
}
public boolean del()
{
EasyJDB db=EasyJDB.getInstance();
return db.del(this);
}
public static List query(String scope)
{
EasyJDB db=EasyJDB.getInstance();
return db.query(BBSDoc.class,scope);
}
public BBSDoc lastUpdate()
{
EasyJDB db=EasyJDB.getInstance();
BBSDoc reply=(BBSDoc)db.read(BBSDoc.class,"parentId='"+this.cid+"' and status>=0 order by inputTime desc");
if(reply==null)
{
reply=new BBSDoc();
reply.setInputTime(this.inputTime);
reply.setInputUser("--");
}
return reply;
}
public String showVRTypesSelect(){
return CommUtil.getSelectOptions(vRTypeTitle,vrtype!=null?vrtype:"");
}
public String showVRTypeTitle()
{
String ret="";
if(vrtype==null || vrtype.equals(""))ret= "无任何限制!";
else if(vrtype.equals("user"))ret= "该主题的内容只有登录后才能显示!";
else if(vrtype.equals("score"))ret="该主题的内容只有积分达到"+this.vrvalue+"的用户才能阅读!";
else if(vrtype.equals("reply"))ret="该主题的内容只有回复后才能阅读!";
else if(vrtype.equals("member"))ret="该主题只有EasyJF开源团队成员才能阅读!";
else if(vrtype.equals("admin"))ret="该主题只有EasyJF管理决策团队才能阅读!";
return ret;
}
public String getKeyField() {
// TODO Auto-generated method stub
return "cid";
}
public String getKeyGenerator() {
// TODO Auto-generated method stub
return "com.easyjf.dbo.RandomIdGenerator";
}
public String getTableName() {
// TODO Auto-generated method stub
return "BBSDoc";
}
//Property accessors
public Integer getBad() {
return bad;
}
public void setBad(Integer bad) {
this.bad = bad;
}
public String getCid() {
return cid;
}
public void setCid(String cid) {
this.cid = cid;
}
public String getClientInfo() {
return clientInfo;
}
public void setClientInfo(String clientInfo) {
this.clientInfo = clientInfo;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getDirSn() {
return dirSn;
}
public void setDirSn(String dirSn) {
this.dirSn = dirSn;
}
public String getFiles() {
return files;
}
public void setFiles(String files) {
this.files = files;
}
public Integer getGood() {
return good;
}
public void setGood(Integer good) {
this.good = good;
}
public String getImgs() {
return imgs;
}
public void setImgs(String imgs) {
this.imgs = imgs;
}
public Date getInputTime() {
return inputTime;
}
public void setInputTime(Date inputTime) {
this.inputTime = inputTime;
}
public String encodeInputUser()
{
String ret=inputUser;
try{
ret=URLEncoder.encode(inputUser.trim(),"utf-8");
}
catch(Exception e)
{
}
return ret;
}
public String getInputUser() {
return inputUser;
}
public void setInputUser(String inputUser) {
this.inputUser = inputUser;
}
public String getIntro() {
return intro;
}
public void setIntro(String intro) {
this.intro = intro;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Integer getReadTimes() {
return readTimes;
}
public void setReadTimes(Integer readTimes) {
this.readTimes = readTimes;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getTagPic() {
return tagPic;
}
public void setTagPic(String tagPic) {
this.tagPic = tagPic;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getVoteScore() {
return voteScore;
}
public void setVoteScore(Integer voteScore) {
this.voteScore = voteScore;
}
public String getVrtype() {
return vrtype;
}
public void setVrtype(String vrtype) {
this.vrtype = vrtype;
}
public String getVrvalue() {
return vrvalue;
}
public void setVrvalue(String vrvalue) {
this.vrvalue = vrvalue;
}
public Integer getEliteMessage() {
return eliteMessage;
}
public void setEliteMessage(Integer eliteMessage) {
this.eliteMessage = eliteMessage;
}
public Integer getTopMessage() {
return topMessage;
}
public void setTopMessage(Integer topMessage) {
this.topMessage = topMessage;
}
public String getLastUpdateUser() {
return lastUpdateUser;
}
public void setLastUpdateUser(String lastUpdateUser) {
this.lastUpdateUser = lastUpdateUser;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getDirPath() {
return dirPath;
}
public void setDirPath(String dirPath) {
this.dirPath = dirPath;
}
public Integer getReplyNum() {
return replyNum;
}
public void setReplyNum(Integer replyNum) {
this.replyNum = replyNum;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -