📄 forumserviceimp.java
字号:
package com.laoer.bbscs.business.service;
import com.laoer.bbscs.business.*;
import java.util.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.dao.IForumDAO;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.sys.*;
import com.laoer.comm.util.*;
import org.apache.struts.upload.*;
/**
* <p>Title: TianYi BBS</p>
* <p>Description: TianYi BBS System</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: LAOER.COM/TIANYISOFT.NET</p>
* @author laoer
* @version 6.0
*/
public class ForumServiceImp
implements IForumService {
private IForumDAO forumDAO;
private IUserInfoService userInfoService;
//private IVoteService voteService;
public ForumServiceImp() {
}
public IForumDAO getForumDAO() {
return this.forumDAO;
}
public void setForumDAO(IForumDAO forumDAO) {
this.forumDAO = forumDAO;
}
public IUserInfoService getUserInfoService() {
return userInfoService;
}
public void setUserInfoService(IUserInfoService userInfoService) {
this.userInfoService = userInfoService;
}
/*
public IVoteService getVoteService() {
return this.voteService;
}
public void setVoteService(IVoteService voteService) {
this.voteService = voteService;
}*/
public Forum saveForum(Forum forum) {
return this.getForumDAO().saveForum(forum);
}
public Forum getForum(long id, long bid) {
return this.getForumDAO().getForum(id, bid);
}
public PageList getForumMainList(long bid, Pages pages) {
//return this.getForumDAO().getForumMainList(bid, pages);
PageList pl = new PageList();
if (pages.getTotals() == -1) {
pages.setTotals(getForumMainNum(bid));
}
pages.doPageBreak();
List l = this.getForumDAO().getForumMainList(bid, pages.getSpage(),
pages.getPerPageNum());
pl.setObjectList(l);
pl.setPageShowString(pages.getListPageBreak());
pl.setPages(pages);
return pl;
}
public PageList getForumAllList(long bid, short delSign, short auditing,
Pages pages) {
//return this.getForumDAO().getForumAllList(bid, delSign, auditing, pages);
PageList pl = new PageList();
if (pages.getTotals() == -1) {
pages.setTotals(getForumAllNum(bid, delSign, auditing));
}
pages.doPageBreak();
List l = this.getForumDAO().getForumAllList(bid, delSign, auditing,
pages.getSpage(),
pages.getPerPageNum());
pl.setObjectList(l);
pl.setPageShowString(pages.getListPageBreak());
pl.setPages(pages);
return pl;
}
public PageList getForumTopicList(long bid, long ID2, Pages pages) {
//return this.getForumDAO().getForumTopicList(bid, ID2, pages);
PageList pl = new PageList();
if (pages.getTotals() == -1) {
pages.setTotals(this.getForumDAO().getForumTopicNum(bid, ID2));
}
pages.doPageBreak();
List l = this.getForumDAO().getForumTopicList(bid, ID2, pages.getSpage(),
pages.getPerPageNum());
pl.setObjectList(l);
pl.setPageShowString(pages.getListPageBreak());
pl.setPages(pages);
return pl;
}
public List getForumTopicList(long bid, long ID2, short delSign,
short auditing) {
return this.getForumDAO().getForumTopicList(bid, ID2, delSign, auditing);
}
public List findForumInList(long bid, List values) {
return this.getForumDAO().findForumInList(bid, values);
}
public List findForumDelAll(long bid) {
return this.getForumDAO().findForumDelAll(bid);
}
public Result createForum(String key, Forum forum, UserCheck uc,
FormFile upfile) {
String detail = forum.getDetail();
if (forum.getIsVote() == 0) {
if (key.equals("new")) {
forum.setDetail("");
forum = this.saveForum(forum);
if (forum != null) {
String filename = "post_" + forum.getId().longValue() + "_" +
forum.getBoardID() +
"_" + forum.getId().longValue() + "_" + forum.getPostTime() +
".html";
StringBuffer sb = new StringBuffer();
sb.append("<html><head><title>");
sb.append(forum.getTitle());
sb.append("</title><body>");
sb.append(detail);
sb.append("</body></html>");
FileIO.writeFile(sb.toString(),
SysUtil.getForumPath(forum.getBoardID(),
forum.getPostTime()) + filename,
Constant.CHARSET);
forum.setDetail(filename);
if (uc.getBs().getAttrib9() == 1) {
if (upfile != null && !Util.nullOrBlank(upfile.getFileName()) &&
upfile.getFileSize() > 0) {
String upFileName = "file_" + forum.getId().longValue() + "_" +
forum.getPostTime() +
SysUtil.getFileExt(upfile.getFileName());
SysUtil.saveUpFile(SysUtil.getUpFilePath(forum.getBoardID(),
forum.getPostTime()) + upFileName, upfile);
forum.setHavePic( (short) 1);
forum.setPicName(upFileName);
}
}
forum.setId2(forum.getId().longValue());
forum = this.saveForum(forum);
if (uc.getBs().getAttrib8() == 0 && uc.getBs().getAttrib4() == 0) {
NewPost.intoNewPost(forum);
}
if (forum == null) {
return new Result(false, "error.posterror", null);
}
else {
return new Result(true, "", forum);
}
}
else {
return new Result(false, "error.posterror", null);
}
}
else {
Forum mainForum = this.getForum(forum.getId2(), forum.getBoardID());
if (mainForum == null) {
return new Result(false, "error.post.getpost", null);
}
if (mainForum.getIsLock() == 1) {
return new Result(false, "error.post.islock", null);
}
if (uc.getBs().getAttrib8() == 0) {
mainForum.setLastPostNickName(forum.getNickName());
mainForum.setLastPostTitle(forum.getTitle());
mainForum.setLastPostUserName(forum.getUserName());
mainForum.setLastTime(forum.getPostTime());
mainForum.setReNum(mainForum.getReNum() + 1);
this.saveForum(mainForum);
}
mainForum = null;
Forum reForum = this.getForum(forum.getId1(), forum.getBoardID());
if (reForum != null && reForum.getCanNotRe() != 1) {
reForum.setCanNotRe( (short) 1);
this.saveForum(reForum);
}
if (forum.getTitle().equals(Constant.RE)) {
if (reForum != null) {
if (reForum.getTitle().startsWith(Constant.RE)) {
forum.setTitle(reForum.getTitle());
}
else {
if (SysUtil.getStrLength(Constant.RE + reForum.getTitle(), Constant.CHARSET) > 90) {
forum.setTitle(reForum.getTitle());
}
else {
forum.setTitle(Constant.RE + reForum.getTitle());
}
}
}
}
forum.setDetail("");
forum = this.saveForum(forum);
if (forum != null) {
String filename = "post_" + forum.getId2() + "_" + forum.getBoardID() +
"_" + forum.getId().longValue() + "_" + forum.getPostTime() +
".html";
StringBuffer sb = new StringBuffer();
sb.append("<html><head><title>");
sb.append(forum.getTitle());
sb.append("</title><body>");
sb.append(detail);
sb.append("</body></html>");
FileIO.writeFile(sb.toString(),
SysUtil.getForumPath(forum.getBoardID(),
forum.getPostTime()) + filename,
Constant.CHARSET);
forum.setDetail(filename);
if (uc.getBs().getAttrib9() == 1) {
if (upfile != null && !Util.nullOrBlank(upfile.getFileName()) &&
upfile.getFileSize() > 0) {
String upFileName = "file_" + forum.getId().longValue() + "_" +
forum.getPostTime() +
SysUtil.getFileExt(upfile.getFileName());
SysUtil.saveUpFile(SysUtil.getUpFilePath(forum.getBoardID(),
forum.getPostTime()) + upFileName, upfile);
forum.setHavePic( (short) 1);
forum.setPicName(upFileName);
}
}
//forum.setId2(forum.getId().longValue());
forum = this.saveForum(forum);
if (forum == null) {
return new Result(false, "error.posterror", null);
}
else {
return new Result(true, "", forum);
}
//return new Result(true, "", forum);
}
else {
return new Result(false, "error.posterror", null);
}
}
}
else {
forum.setDetail("");
forum = this.saveForum(forum);
if (forum != null) {
String filename = "post_" + forum.getId().longValue() + "_" +
forum.getBoardID() +
"_" + forum.getId().longValue() + "_" + forum.getPostTime() +
".html";
StringBuffer sb = new StringBuffer();
sb.append("<html><head><title>");
sb.append(forum.getTitle());
sb.append("</title><body>");
sb.append(
"<form name=\"voteDoForm\" method=\"post\" action=\"voteDo");
sb.append(Constant.FILEPREFIX);
sb.append("\"><input name=\"action\" type=\"hidden\" value='");
sb.append("vote");
sb.append("'>\n");
sb.append("<input name=\"postid\" type=\"hidden\" value='");
sb.append(forum.getId().longValue());
sb.append("'>\n");
sb.append("<input name=\"bid\" type=\"hidden\" id=\"bid\" value='");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -