📄 read.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.exception.*;
import com.laoer.bbscs.service.*;
import com.laoer.bbscs.service.config.*;
import com.laoer.bbscs.service.web.*;
import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.web.servlet.*;
public class Read
extends BaseAction {
private ForumService forumService;
private BoardService boardService;
private SysConfig sysConfig;
private IPSeeker ipSeeker;
private UserService userService;
private EliteService eliteService;
private ForumHistoryService forumHistoryService;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
ReadForm readForm = (ReadForm) form;
ActionMessages messages = new ActionMessages();
//UserSession us = this.getUserSession(request);
UserCookie uc = this.getUserCookie(request, response, this.getSysConfig());
long bid = readForm.getBid();
//Board board = this.getBoardService().getBoardByID(bid);
//request.setAttribute("board", board);
Board board = (Board) request.getAttribute(Constant.BOARD_REQUEST_KEY);
if (board == null) {
//System.out.println("Board not in request...");
board = this.getBoardService().getBoardByID(bid);
request.setAttribute("board", board);
}
if (readForm.getAction().equalsIgnoreCase("topic")) {
Pages pages = new Pages();
pages.setPage(readForm.getInpages());
//pages.setPerPageNum(1);
pages.setPerPageNum(this.getUserPostPerNum(uc.getPostPerNum(),
this.getSysConfig().getPostPerPage()));
pages.setFileName(BBSCSUtil.getActionMappingURL("/read?action=" + readForm.getAction() +
"&bid=" + bid + "&id=" + readForm.getId() + "&fcpage=" + readForm.getFcpage() + "&fcaction=" +
readForm.getFcaction(), request));
PageList pl = this.getForumService().findForumsTopic(bid, readForm.getId(), pages);
if (pl.getObjectList().size() == 0) { //主表中没有,尝试查询历史表
//messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
//this.saveErrors(request, messages);
//return mapping.getInputForward();
pages = new Pages();
pages.setPage(readForm.getInpages());
pages.setPerPageNum(this.getUserPostPerNum(uc.getPostPerNum(),
this.getSysConfig().getPostPerPage()));
pages.setFileName(BBSCSUtil.getActionMappingURL("/readHistory?action=" + readForm.getAction() +
"&bid=" + bid + "&id=" + readForm.getId() + "&fcpage=" + readForm.getFcpage() + "&fcaction" +
readForm.getFcaction(), request));
pl = this.getForumHistoryService().findForumsTopic(bid, readForm.getId(), pages);
if (pl.getObjectList().size() == 0) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
String title = "";
ForumHistory f = (ForumHistory) pl.getObjectList().get(0);
if (f.getIsNew() == 1) {
f.setClick(f.getClick() + 1);
try {
this.getForumHistoryService().updateForumHistory(f);
}
catch (BbscsException ex) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
}
else {
if (readForm.getInpages() == 1) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
}
title = f.getTitle();
request.setAttribute("pl", pl);
request.setAttribute("title", title);
List pboards = this.getBoardService().findParentBoards(board.getParentIDs());
request.setAttribute("pboards", pboards);
request.setAttribute("mainid", readForm.getId());
request.setAttribute("fcpage", new Integer(readForm.getFcpage()));
request.setAttribute("inpages", new Integer(readForm.getInpages()));
request.setAttribute("totalnum", new Integer(pl.getPages().getTotalNum()));
return mapping.findForward("readHistory");
}
String title = "";
Forum f = (Forum) pl.getObjectList().get(0);
if (f.getIsNew() == 1) {
f.setClick(f.getClick() + 1);
try {
f = this.getForumService().saveForum(f);
if (f.getClick() == this.getSysConfig().getForumHotViews()) {
UserInfo ui = this.getUserService().findUserInfoById(f.getUserID());
if (ui != null) {
ui.setLiterary(ui.getLiterary() + 1); //增加用户文采值
this.getUserService().saveUserInfo(ui);
}
}
}
catch (BbscsException ex) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
}
else {
if (readForm.getInpages() == 1) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
}
title = f.getTitle();
request.setAttribute("pl", pl);
request.setAttribute("title", title);
List pboards = this.getBoardService().findParentBoards(board.getParentIDs());
request.setAttribute("pboards", pboards);
PostForm postForm = new PostForm();
postForm.setAction("addqre");
postForm.setEditType(0);
/*
if (this.getSysConfig().getEditInterface() == 0) {
postForm.setEditType(0);
}
else if (this.getSysConfig().getEditInterface() == 1) {
postForm.setEditType(1);
}
else {
postForm.setEditType(2);
}*/
postForm.setSign( -1);
postForm.setBid(bid);
postForm.setInpages(readForm.getInpages());
postForm.setMainID(readForm.getId());
postForm.setTitle(Constant.RE);
postForm.setTotalnum(pl.getPages().getTotalNum());
postForm.setParentID(readForm.getId());
postForm.setPage(readForm.getFcpage());
postForm.setFcpage(readForm.getFcpage());
request.setAttribute("postForm", postForm);
request.setAttribute("mainid", readForm.getId());
request.setAttribute("fcpage", new Integer(readForm.getFcpage()));
request.setAttribute("inpages", new Integer(readForm.getInpages()));
request.setAttribute("totalnum", new Integer(pl.getPages().getTotalNum()));
//request.setAttribute("fcaction", readForm.getFcaction());
return mapping.findForward("read");
}
if (readForm.getAction().equalsIgnoreCase("own")) {
Forum f = this.getForumService().findForumByID(readForm.getId(), readForm.getBid());
if (f == null) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
Pages pages = new Pages();
pages.setPage(readForm.getInpages());
//pages.setPerPageNum(1);
pages.setPerPageNum(this.getUserPostPerNum(uc.getPostPerNum(),
this.getSysConfig().getPostPerPage()));
pages.setFileName(BBSCSUtil.getActionMappingURL("/read?action=" + readForm.getAction() +
"&bid=" + bid + "&id=" + readForm.getId() + "&fcpage=" + readForm.getFcpage() + "&fcaction=" +
readForm.getFcaction(), request));
PageList pl = this.getForumService().findForumsOwner(bid, f.getUserID(), readForm.getId(), pages);
if (pl.getObjectList().size() == 0) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.getInputForward();
}
request.setAttribute("pl", pl);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -