📄 webmessageaction.java
字号:
package com.easyjf.bbs.action;
import java.util.Date;
import com.easyjf.bbs.business.ActiveUser;
import com.easyjf.bbs.business.BBSRights;
import com.easyjf.bbs.business.WebMessage;
import com.easyjf.bbs.business.util.MessageUtil;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
import com.easyjf.web.tools.IPageList;
public class WebMessageAction extends AbstractCmdAction {
public WebMessageAction() {
super();
// TODO Auto-generated constructor stub
}
public Page doInit(WebForm form, Module module) {
// TODO Auto-generated method stub
return null;
}
public Page doWrite(WebForm form, Module module) {
String toname = CommUtil.null2String(form.get("toname"));
if (!"".equals(toname)) {
form.addResult("toname", toname);
}
return module.findPage("write");
}
public Page doListRecv(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "list", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
int currentPage = CommUtil.null2Int(form.get("page"));
int pageSize = CommUtil.null2Int(form.get("pageSize"));
if (currentPage < 1)
currentPage = 1;
if (pageSize < 1)
pageSize = 15;
IPageList pList = MessageUtil.queryRecv("toname='"
+ this.getCurrentUser().getUserName() + "'", pageSize,
currentPage);
if (pList != null) {
form.addResult("type", "收件箱");
form.addResult("list", pList.getResult());
form.addResult("pages", new Integer(pList.getPages()));
form.addResult("rows", new Integer(pList.getRowCount()));
form.addResult("page", new Integer(pList.getCurrentPage()));
form.addResult("gotoPageHTML", CommUtil.showPageHtml(pList
.getCurrentPage(), pList.getPages()));
}
return module.findPage("list");
}
public Page doListSend(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "list", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
int currentPage = CommUtil.null2Int(form.get("page"));
int pageSize = CommUtil.null2Int(form.get("pageSize"));
if (currentPage < 1)
currentPage = 1;
if (pageSize < 1)
pageSize = 15;
IPageList pList = MessageUtil.querySend("fromname='"
+ this.getCurrentUser().getUserName() + "'", pageSize,
currentPage);
if (pList != null) {
form.addResult("type", "发件箱");
form.addResult("list", pList.getResult());
form.addResult("pages", new Integer(pList.getPages()));
form.addResult("rows", new Integer(pList.getRowCount()));
form.addResult("page", new Integer(pList.getCurrentPage()));
form.addResult("gotoPageHTML", CommUtil.showPageHtml(pList
.getCurrentPage(), pList.getPages()));
}
return module.findPage("list");
}
public Page doListUnread(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "list", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
int currentPage = CommUtil.null2Int(form.get("page"));
int pageSize = CommUtil.null2Int(form.get("pageSize"));
if (currentPage < 1)
currentPage = 1;
if (pageSize < 1)
pageSize = 15;
IPageList pList = MessageUtil.queryUnRead("toname='"
+ this.getCurrentUser().getUserName() + "'", pageSize,
currentPage);
if (pList != null) {
form.addResult("type", "未读邮件");
form.addResult("list", pList.getResult());
form.addResult("pages", new Integer(pList.getPages()));
form.addResult("rows", new Integer(pList.getRowCount()));
form.addResult("page", new Integer(pList.getCurrentPage()));
form.addResult("gotoPageHTML", CommUtil.showPageHtml(pList
.getCurrentPage(), pList.getPages()));
}
return module.findPage("list");
}
public Page doUnreadCount(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "list", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
form.addResult("unreadcount", WebMessage.UnReadNum(this
.getCurrentUser().getUserName()));
return module.findPage("main");
}
public Page doRead(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "read", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
String cid = CommUtil.null2String(form.get("cid"));
if (!"".equals(cid)) {
WebMessage wm = WebMessage.read(cid);
form.addResult("title", wm.getTitle());
form.addResult("fromname", wm.getFromname());
form.addResult("message", wm.getMessage());
form.addResult("date", wm.getSenddate());
if (MessageUtil.isread(wm)) {
MessageUtil.read(wm);
if (wm.getACK().intValue() == 1) {
MessageUtil.sendSystemMessage(WebMessage.ACKMSG, wm
.getToname());
}
}
}
return module.findPage("show");
}
public Page doSend(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "send", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
String fromname = this.getCurrentUser().getUserName();
String toname = CommUtil.null2String(form.get("toname"));
String title = CommUtil.null2String(form.get("title"));
String message = CommUtil.null2String(form.get("message"));
String ACK = CommUtil.null2String(form.get("ACK"));
WebMessage wm = new WebMessage();
wm.setACK(new Integer(ACK));
wm.setFromname(fromname);
wm.setIsRead(new Integer(0));
wm.setMessage(message);
wm.setSenddate(new Date());
wm.setStatus(new Integer(0));
wm.setTitle(title);
wm.setToname(this.getCurrentUser().getUserName());
wm.setType(new Integer(0));
wm.setToname(toname);
if (wm.save()) {
form.addResult("msg", "发送成功!");
}
return this.doListSend(form, module);
}
public Page doSendUsers(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "send", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
String fromname = this.getCurrentUser().getUserName();
String toname = CommUtil.null2String(form.get("tonames"));
String[] tonames = toname.split(";");
boolean ret = false;
for (int i = 0; i < tonames.length; i++) {
String title = CommUtil.null2String(form.get("title"));
String message = CommUtil.null2String(form.get("message"));
String ACK = CommUtil.null2String(form.get("ACK"));
WebMessage wm = new WebMessage();
wm.setACK(new Integer(ACK));
wm.setFromname(fromname);
wm.setIsRead(new Integer(0));
wm.setMessage(message);
wm.setSenddate(new Date());
wm.setStatus(new Integer(0));
wm.setTitle(title);
wm.setToname(this.getCurrentUser().getUserName());
wm.setType(new Integer(0));
wm.setToname(tonames[i]);
ret = wm.save();
}
if (ret) {
form.addResult("msg", "发送成功!");
}
return this.doListSend(form, module);
}
public Page doDel(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "del", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
String cid = CommUtil.null2String(form.get("cid"));
if (!"".equals(cid)) {
WebMessage wm = WebMessage.read(cid);
if (MessageUtil.del(wm, this.getCurrentUser().getUserName())) {
form.addResult("msg", "删除成功");
}
}
return this.doListRecv(form, module);
}
public Page doMessage(WebForm form, Module module) {
if (!BBSRights.checkRights(new WebMessage(), "msg", getCurrentUser()))
return new Page("popedomError", "/bbs/norights.htm", "page");
return module.findPage("main");
}
private ActiveUser getCurrentUser() {
ActiveUser user = (ActiveUser) ActionContext.getContext().getSession()
.getAttribute("bbsuser");
return user;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -