📄 voteopt.java
字号:
package com.laoer.bbscs.web.action;
import java.util.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.comm.*;
import com.laoer.bbscs.service.*;
import com.laoer.bbscs.service.config.*;
import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.exception.*;
public class VoteOpt
extends BaseAction {
private ForumService forumService;
private BoardService boardService;
private SysConfig sysConfig;
private AjaxMessagesXML ajaxMessagesXML;
private VoteUserService voteUserService;
private VoteItemService voteItemService;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
VoteOptForm voteOptForm = (VoteOptForm) form;
UserSession us = this.getUserSession(request);
UserCookie uc = this.getUserCookie(request, response, this.getSysConfig());
long bid = voteOptForm.getBid();
Board board = (Board) request.getAttribute(Constant.BOARD_REQUEST_KEY);
if (board == null) {
board = this.getBoardService().getBoardByID(bid);
//request.setAttribute("board", board);
}
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
if (voteOptForm.getDeadline() < System.currentTimeMillis()) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_VOTE_DEADLINE,
mr.getMessage(locale, "error.vote.deadline1"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (voteOptForm.getVoteitemid() == null || voteOptForm.getVoteitemid().length == 0) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_VOTE_SELITEM,
mr.getMessage(locale, "error.vote.selectitem"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
Forum f = this.getForumService().findForumByID(voteOptForm.getPostid(), bid);
if (f == null) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_NOT_EXIST,
mr.getMessage(locale, "error.post.getpost"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
if (this.getVoteUserService().findVoteUserByVoteIDUserID(voteOptForm.getVoteid(), us.getId()) != null) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_VOTE_USER_EXIST,
mr.getMessage(locale, "error.vote.userexist"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
try {
this.getVoteItemService().createVoteItemAdd(us.getId(), voteOptForm.getVoteid(),
voteOptForm.getVoteitemid());
if (this.getSysConfig().getVoteUpdatePost() == 1) {
f.setLastTime(System.currentTimeMillis());
this.getForumService().saveForum(f);
}
}
catch (BbscsException ex1) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_VOTE_ERROR,
mr.getMessage(locale, "error.post.vote.error"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
/*
for (int i = 0; i < voteOptForm.getVoteitemid().length; i++) {
VoteItem vi = this.getVoteItemService().findVoteItemByID(voteOptForm.getVoteitemid()[i]);
if (vi != null) {
vi.setItemValue(vi.getItemValue() + 1);
try {
this.getVoteItemService().saveVoteItem(vi);
}
catch (BbscsException ex) {
this.getAjaxMessagesXML().setMessage(Constant.CODEID_POST_VOTE_ERROR,
mr.getMessage(locale, "error.post.vote.error"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
}
}
}*/
this.getAjaxMessagesXML().setMessage(Constant.CODEID_OK, mr.getMessage(locale, "post.vote.ok"));
this.setAjaxMessagesXMLRepuest(request, this.getAjaxMessagesXML());
return mapping.findForward(this.FORWARD_AJAX);
//return mapping.getInputForward();
}
public BoardService getBoardService() {
return boardService;
}
public ForumService getForumService() {
return forumService;
}
public SysConfig getSysConfig() {
return sysConfig;
}
public AjaxMessagesXML getAjaxMessagesXML() {
return ajaxMessagesXML;
}
public VoteUserService getVoteUserService() {
return voteUserService;
}
public VoteItemService getVoteItemService() {
return voteItemService;
}
public void setBoardService(BoardService boardService) {
this.boardService = boardService;
}
public void setForumService(ForumService forumService) {
this.forumService = forumService;
}
public void setSysConfig(SysConfig sysConfig) {
this.sysConfig = sysConfig;
}
public void setAjaxMessagesXML(AjaxMessagesXML ajaxMessagesXML) {
this.ajaxMessagesXML = ajaxMessagesXML;
}
public void setVoteUserService(VoteUserService voteUserService) {
this.voteUserService = voteUserService;
}
public void setVoteItemService(VoteItemService voteItemService) {
this.voteItemService = voteItemService;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -