📄 subscibeaction.java
字号:
package com.laoer.bbscs.bbs.action;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.laoer.bbscs.bbs.actionform.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.servlet.*;
import com.laoer.bbscs.db.*;
import org.apache.struts.util.*;
import java.util.*;
public class SubscibeAction
extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionErrors errors = new ActionErrors();
SubscibeActionForm form = (SubscibeActionForm) actionForm;
UserSessionCheck myUserSessionCheck = new UserSessionCheck(form.getSid(),
httpServletRequest);
if (!myUserSessionCheck.checkSession(form.getBid())) {
errors.add("error.timeout", new ActionError("error.timeout"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (myUserSessionCheck.isGuest()) {
errors.add("noguest", new ActionError("error.user.noguest"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
httpServletRequest.setAttribute("myUserSessionCheck", myUserSessionCheck);
httpServletRequest.setAttribute("sid", form.getSid());
httpServletRequest.setAttribute("bid", form.getBid());
httpServletRequest.setAttribute("theBoards",
myUserSessionCheck.getTheBoards());
if (form.getAction().equals("add")) {
SubscibeInfo aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setID(String.valueOf(Util.getaLongTime()) +
String.valueOf(myUserSessionCheck.getUserID()));
aSubscibeInfo.setBID(Long.parseLong(form.getBid()));
aSubscibeInfo.setRID(Long.parseLong(form.getRid()));
aSubscibeInfo.setUserID(myUserSessionCheck.getUserID());
aSubscibeInfo.setUname(myUserSessionCheck.getUserName());
ForumInfo afi = new ForumInfo();
afi.setBoardID(Long.parseLong(form.getBid()));
afi.setID(Long.parseLong(form.getRid()));
Forum af = ForumFactory.getInstance();
af.setForumInfo(afi);
if (af.getPost(null, "ID", true) != Sys.RESULT_RIGHT) {
errors.add("getpost", new ActionError("error.post.getpost"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
afi = af.getForumInfo();
aSubscibeInfo.setPostTitle(afi.getTitle());
aSubscibeInfo.setEmail_inform(1);
aSubscibeInfo.setMsg_inform(1);
Subscibe aSubscibe = SubscibeFactory.getInstance();
aSubscibe.setSubscibeInfo(aSubscibeInfo);
int result = aSubscibe.getSubscibe(null, "repeat", false);
if (result == Sys.RESULT_RIGHT) {
errors.add("subscibe.already", new ActionError("error.subscibe.already"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (result != Sys.RESULT_OBJECTNOEXISTEXCEPTION) {
errors.add("subscibe", new ActionError("error.subscibe"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
result = aSubscibe.createSubscibe(null);
if (result != Sys.RESULT_RIGHT) {
errors.add("subscibe", new ActionError("error.subscibe"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("succeed.subscibe",
"", true, false, 0, 1));
return actionMapping.findForward("forwards");
}
if (form.getAction().equals("show")) {
MessageResources messages = getResources(httpServletRequest);
Locale locale = getLocale(httpServletRequest);
Pages myPages = PagesFactory.getInstance();
String[] pagessign = {
messages.getMessage(locale, "bbscs.pages.first"),
messages.getMessage(locale, "bbscs.pages.previous"),
messages.getMessage(locale, "bbscs.pages.next"),
messages.getMessage(locale, "bbscs.pages.end")};
myPages.setPagesign(pagessign);
myPages.setPerPageNum(Sys.SYSINFO.FORUMPERNUM);
//myPages.setPerPageNum(1);
myPages.setPages(Integer.parseInt(form.getPages()));
myPages.setFileName(Sys.getURL() + "subscibeAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&action=show&");
SubscibeInfo aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setBID(Long.parseLong(form.getBid()));
aSubscibeInfo.setUserID(myUserSessionCheck.getUserID());
aSubscibeInfo.setUname(myUserSessionCheck.getUserName());
Subscibe aSubscibe = SubscibeFactory.getInstance();
aSubscibe.setSubscibeInfo(aSubscibeInfo);
aSubscibe.setPages(myPages);
List mylist = aSubscibe.getSubscibeList(null, "mySubscibe");
String pagebreakstr = aSubscibe.getListPageBreak();
httpServletRequest.setAttribute("sublist", mylist);
httpServletRequest.setAttribute("pages", form.getPages());
httpServletRequest.setAttribute("pagebreakstr", pagebreakstr);
return actionMapping.findForward("mysub");
}
if (form.getAction().equals("delemail")) {
SubscibeInfo aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setID(form.getSubid());
aSubscibeInfo.setBID(Long.parseLong(form.getBid()));
Subscibe aSubscibe = SubscibeFactory.getInstance();
aSubscibe.setSubscibeInfo(aSubscibeInfo);
if (aSubscibe.getSubscibe(null, "ID", true) == Sys.RESULT_RIGHT) {
aSubscibeInfo = aSubscibe.getSubscibeInfo();
if (aSubscibeInfo.getMsg_inform() == 0) {
aSubscibe.delSubscibe(null);
}
else {
aSubscibeInfo.setEmail_inform(Integer.parseInt(form.getEmail_inform()));
aSubscibe.setSubscibeInfo(aSubscibeInfo);
aSubscibe.updateSubscibe(null, "dy");
}
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("succeed.jrzc",
Sys.getURL() + "subscibeAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&action=show&pages=" + form.getPages()));
return actionMapping.findForward("forwards");*/
ActionForward f = new ActionForward("/subscibeAction.do?sid=" +
form.getSid() +
"&bid=" + form.getBid() +
"&action=show&pages=" + form.getPages(), true);
return f;
}
if (form.getAction().equals("delmsg")) {
SubscibeInfo aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setID(form.getSubid());
aSubscibeInfo.setBID(Long.parseLong(form.getBid()));
Subscibe aSubscibe = SubscibeFactory.getInstance();
aSubscibe.setSubscibeInfo(aSubscibeInfo);
if (aSubscibe.getSubscibe(null, "ID", true) == Sys.RESULT_RIGHT) {
aSubscibeInfo = aSubscibe.getSubscibeInfo();
if (aSubscibeInfo.getEmail_inform() == 0) {
aSubscibe.delSubscibe(null);
}
else {
aSubscibeInfo.setMsg_inform(Integer.parseInt(form.getMsg_inform()));
aSubscibe.setSubscibeInfo(aSubscibeInfo);
aSubscibe.updateSubscibe(null, "dy");
}
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("succeed.jrzc",
Sys.getURL() + "subscibeAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&action=show&pages=" + form.getPages()));
return actionMapping.findForward("forwards");*/
ActionForward f = new ActionForward("/subscibeAction.do?sid=" +
form.getSid() +
"&bid=" + form.getBid() +
"&action=show&pages=" + form.getPages(), true);
return f;
}
if (form.getAction().equals("delall")) {
SubscibeInfo aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setID(form.getSubid());
aSubscibeInfo.setBID(Long.parseLong(form.getBid()));
Subscibe aSubscibe = SubscibeFactory.getInstance();
aSubscibe.setSubscibeInfo(aSubscibeInfo);
aSubscibe.delSubscibe(null);
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("succeed.jrzc",
Sys.getURL() + "subscibeAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&action=show&pages=" + form.getPages()));
return actionMapping.findForward("forwards");*/
ActionForward f = new ActionForward("/subscibeAction.do?sid=" +
form.getSid() +
"&bid=" + form.getBid() +
"&action=show&pages=" + form.getPages(), true);
return f;
}
return actionMapping.findForward("error");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -