covermanage.java
来自「一个jsp写的bbs」· Java 代码 · 共 330 行
JAVA
330 行
package com.laoer.bbscs.web.action;
import java.util.*;
import javax.servlet.http.*;
import org.apache.commons.lang.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.comm.*;
import com.laoer.bbscs.dao.*;
import com.laoer.bbscs.exception.*;
import com.laoer.bbscs.service.*;
import com.laoer.bbscs.service.web.*;
import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.web.servlet.*;
public class CoverManage
extends BaseAction {
private BoardService boardService;
private CommendService commendService;
private AjaxMessagesXML ajaxMessagesXML;
private ChoiceService choiceService;
private ForumService forumService;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
CoverManageForm coverManageForm = (CoverManageForm) form;
long bid = coverManageForm.getBid();
UserSession us = this.getUserSession(request);
//Board board = (Board) request.getAttribute(Constant.BOARD_REQUEST_KEY);
//if (board == null) {
// board = this.getBoardService().getBoardByID(bid);
//}
if (coverManageForm.getAction().equalsIgnoreCase("index")) {
Board board = (Board) request.getAttribute(Constant.BOARD_REQUEST_KEY);
if (board == null) {
board = this.getBoardService().getBoardByID(bid);
}
request.setAttribute("board", board);
//List l = this.getChoiceService().findChoiceCategorysByBoardId(bid, -1);
//request.setAttribute("cclist", l);
return mapping.findForward("coverManage");
}
if (coverManageForm.getAction().equalsIgnoreCase("commendlist")) {
Pages pages = new Pages();
pages.setPage(coverManageForm.getPage());
pages.setPerPageNum(10);
pages.setFileName(BBSCSUtil.getActionMappingURL("/coverManage?action=" + coverManageForm.getAction() +
"&ajax=shtml", request));
PageList pl = this.getCommendService().findCommendsByCommendBoardID(bid, pages);
request.setAttribute("pl", pl);
return mapping.findForward("cmCommendList");
}
if (coverManageForm.getAction().equalsIgnoreCase("delcs")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (coverManageForm.getCommendIds() == null || coverManageForm.getCommendIds().length == 0) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_IDSISNULL,
mr.getMessage(locale, "error.note.ids.null"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
try {
this.getCommendService().removeCommend(bid, BBSCSUtil.stringValues2List(coverManageForm.getCommendIds()));
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.delcommend.ok"));
}
catch (BbscsException ex) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_DELCOMMEND,
mr.getMessage(locale, "covermanage.delcommend.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("cclist")) {
List l = this.getChoiceService().findChoiceCategorysByBoardId(bid, -1);
request.setAttribute("cclist", l);
return mapping.findForward("cmCcList");
}
if (coverManageForm.getAction().equalsIgnoreCase("cnew")) {
coverManageForm.setUseStat(1);
return mapping.findForward("cmCategory");
}
if (coverManageForm.getAction().equalsIgnoreCase("cadd")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (StringUtils.isBlank(coverManageForm.getCategoryName())) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_NAME_NULL,
mr.getMessage(locale, "covermanage.categoryname.null"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
ChoiceCategory cc = new ChoiceCategory();
cc.setBoardID(bid);
cc.setCategoryName(coverManageForm.getCategoryName());
cc.setOrders(coverManageForm.getOrders());
cc.setUseStat(coverManageForm.getUseStat());
try {
this.getChoiceService().saveChoiceCategory(cc);
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.category.add.ok"));
}
catch (BbscsException ex1) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_ADD_ERROR,
mr.getMessage(locale, "covermanage.category.add.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("cedit")) {
ChoiceCategory cc = this.getChoiceService().findChoiceCategoryById(coverManageForm.getCategoryID());
if (cc != null) {
coverManageForm.setCategoryName(cc.getCategoryName());
coverManageForm.setOrders(cc.getOrders());
coverManageForm.setUseStat(cc.getUseStat());
return mapping.findForward("cmCategory");
}
else {
return mapping.findForward(this.FORWARD_HTMLERROR);
}
}
if (coverManageForm.getAction().equalsIgnoreCase("ceditdo")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (StringUtils.isBlank(coverManageForm.getCategoryName())) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_NAME_NULL,
mr.getMessage(locale, "covermanage.categoryname.null"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
ChoiceCategory cc = this.getChoiceService().findChoiceCategoryById(coverManageForm.getCategoryID());
cc.setCategoryName(coverManageForm.getCategoryName());
cc.setOrders(coverManageForm.getOrders());
cc.setUseStat(coverManageForm.getUseStat());
try {
this.getChoiceService().saveChoiceCategory(cc);
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.category.edit.ok"));
}
catch (BbscsException ex1) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_EDIT_ERROR,
mr.getMessage(locale, "covermanage.category.edit.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("cdel")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
ChoiceCategory cc = this.getChoiceService().findChoiceCategoryById(coverManageForm.getCategoryID());
if (cc != null) {
try {
this.getChoiceService().removeChoiceCategory(cc);
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.category.del.ok"));
}
catch (BbscsException ex2) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_DEL_ERROR,
mr.getMessage(locale, "covermanage.category.del.error"));
}
}
else {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CATEGORY_DEL_ERROR,
mr.getMessage(locale, "covermanage.category.del.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("choicelist")) {
List l = this.getChoiceService().findChoicesByCategoryID(coverManageForm.getCategoryID());
request.setAttribute("choicelist", l);
return mapping.findForward("cmChoiceList");
}
if (coverManageForm.getAction().equalsIgnoreCase("choiceadd")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (StringUtils.isBlank(coverManageForm.getPostID())) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CHOICE_POSTID_NULL,
mr.getMessage(locale, "covermanage.choice.postid.null"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
Choice c = this.getChoiceService().findChoiceByCategoryIDPostID(coverManageForm.getCategoryID(),
coverManageForm.getPostID());
if (c != null) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CHOICE_EXIST,
mr.getMessage(locale, "covermanage.choice.exist"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
Forum f = this.getForumService().findForumByID(coverManageForm.getPostID());
if (f == null) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
mr.getMessage(locale, "covermanage.choice.postnoexist"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
c = new Choice();
c.setBoardID(f.getBoardID());
c.setBoardName(f.getBoardName());
c.setCategoryID(coverManageForm.getCategoryID());
c.setCreateTime(System.currentTimeMillis());
c.setPostID(f.getId());
c.setPostMainID(f.getMainID());
c.setTitle(f.getTitle());
c.setUserID(f.getUserID());
c.setUserName(f.getUserName());
c.setUserNickName(f.getNickName());
try {
this.getChoiceService().saveChoice(c);
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.choice.add.ok"));
}
catch (BbscsException ex3) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CHOICE_ADD_ERROR,
mr.getMessage(locale, "covermanage.choice.add.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("choicedels")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (coverManageForm.getChoiceIds() != null) {
try {
this.getChoiceService().removeChoices(BBSCSUtil.stringValues2List(coverManageForm.getChoiceIds()));
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.choice.del.ok"));
}
catch (BbscsException ex4) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CHOICE_DEL_ERROR,
mr.getMessage(locale, "covermanage.choice.del.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
}
if (coverManageForm.getAction().equalsIgnoreCase("choicefile")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
try {
this.getChoiceService().createChoicePage(bid);
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK,
mr.getMessage(locale, "covermanage.choice.file.ok"));
}
catch (BbscsException ex5) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_COVERMANAGE_CHOICE_FILE_ERROR,
mr.getMessage(locale, "covermanage.choice.file.error"));
}
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (coverManageForm.getAction().equalsIgnoreCase("inmanage")) {
return mapping.findForward("inCoverManage");
}
return mapping.findForward(this.FORWARD_ERROR);
}
public BoardService getBoardService() {
return boardService;
}
public CommendService getCommendService() {
return commendService;
}
public AjaxMessagesXML getAjaxMessagesXML() {
return ajaxMessagesXML;
}
public ChoiceService getChoiceService() {
return choiceService;
}
public ForumService getForumService() {
return forumService;
}
public void setBoardService(BoardService boardService) {
this.boardService = boardService;
}
public void setCommendService(CommendService commendService) {
this.commendService = commendService;
}
public void setAjaxMessagesXML(AjaxMessagesXML ajaxMessagesXML) {
this.ajaxMessagesXML = ajaxMessagesXML;
}
public void setChoiceService(ChoiceService choiceService) {
this.choiceService = choiceService;
}
public void setForumService(ForumService forumService) {
this.forumService = forumService;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?