📄 messageutil.java
字号:
package com.easyjf.bbs.business.util;
import java.util.Date;
import com.easyjf.bbs.business.config.*;
import com.easyjf.bbs.business.WebMessage;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IPageList;
public class MessageUtil {
public MessageUtil() {
super();
// TODO Auto-generated constructor stub
}
public static boolean del(WebMessage wm, String username) {
if (wm.getType().intValue() == WebMessage.SYSTEMSENDMSG) {
return wm.del();
}
if (wm.getType().intValue() == WebMessage.NORMALMSG) {
if (username.equals(wm.getFromname())) {
if (wm.getStatus().intValue() == WebMessage.NORMAL) {
wm.setStatus(new Integer(WebMessage.SENDDEL));
return wm.update();
} else if (wm.getStatus().intValue() == WebMessage.REVDEL) {
return wm.del();
}
} else if (username.equals(wm.getToname())) {
if (wm.getStatus().intValue() == WebMessage.NORMAL) {
wm.setStatus(new Integer(WebMessage.REVDEL));
return wm.update();
} else if (wm.getStatus().intValue() == WebMessage.SENDDEL) {
return wm.del();
}
}
}
return true;
}
public static boolean read(WebMessage wm) {
if (wm.getIsRead().intValue() == WebMessage.UNREAD) {
wm.setIsRead(new Integer(WebMessage.READ));
return wm.update();
}
return true;
}
public static boolean isread(WebMessage wm) {
if (wm.getIsRead().intValue() == WebMessage.UNREAD) {
return true;
}
return false;
}
public static IPageList queryUnRead(String scope, int pageSize, int pageNo) {
DbPageList pList = new DbPageList(WebMessage.class, scope
+ " and isread=" + WebMessage.UNREAD + " and status in ("
+ WebMessage.NORMAL + " , " + WebMessage.SENDDEL
+ ") and type in (" + WebMessage.NORMALMSG + " , "
+ WebMessage.SYSTEMSENDMSG + ")", null);
pList.doList(pageNo, pageSize);
return pList;
}
public static IPageList querySend(String scope, int pageSize, int pageNo) {
DbPageList pList = new DbPageList(WebMessage.class, scope
+ " and type=" + WebMessage.NORMALMSG + " and status in ("
+ WebMessage.NORMAL + " , " + WebMessage.REVDEL + " )", null);
pList.doList(pageNo, pageSize);
return pList;
}
public static IPageList queryRecv(String scope, int pageSize, int pageNo) {
DbPageList pList = new DbPageList(WebMessage.class, scope
+ " and status in (" + WebMessage.NORMAL + " , "
+ WebMessage.SENDDEL + " ) and type in ("
+ WebMessage.NORMALMSG + " , " + WebMessage.SYSTEMSENDMSG
+ " )", null);
pList.doList(pageNo, pageSize);
return pList;
}
public static boolean sendSystemMessage(String type, String toname) {
WebMessage wm = (WebMessage) BBSConfig.getInstance().getMessages().get(type.trim());
wm.setCid(null);
String message=wm.getMessage();
message=message.replaceAll("#username",toname);
wm.setMessage(message);
wm.setType(new Integer(WebMessage.SYSTEMSENDMSG));
wm.setStatus(new Integer(WebMessage.NORMAL));
wm.setToname(toname);
wm.setIsRead(new Integer(WebMessage.UNREAD));
wm.setSenddate(new Date());
wm.setACK(new Integer(0));
return wm.save();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -