📄 forumserviceimp.java
字号:
pages.setTotalNum(this.getForumNumHotTopic(bids, reNum, click));
}
pages.executeCount();
List l = this.getForumDAO().findForumsHotTopic(bids, reNum, click, pages.getSpage(), pages.getPerPageNum());
pl.setObjectList(l);
pl.setPages(pages);
return pl;
}
public void removeToHistory(long atime) throws BbscsException {
List ml = this.getForumDAO().findForumsToHistory(atime);
for (int i = 0; i < ml.size(); i++) {
Forum f = (Forum) ml.get(i);
List fl = this.getForumDAO().findForumsTopic(f.getBoardID(), f.getId(), 0, 0, null, 0);
for (int j = 0; j < fl.size(); j++) {
Forum mf = (Forum) fl.get(j);
ForumHistory fh = new ForumHistory();
try {
BeanUtils.copyProperties(fh, mf);
this.getForumHistoryDAO().saveForumHistory(fh);
this.getForumDAO().removeForum(mf);
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
}
public List findForumsInIds(long bid, List ids) {
return this.getForumDAO().findForumsInIds(bid, ids);
}
public List findForumsInIds(List ids) {
return this.getForumDAO().findForumsInIds(ids);
}
public void delPostReal(Forum forum) throws BbscsException {
try {
if (forum.getHaveAttachFile() == 1 && forum.getAttachFileName() != null &&
forum.getAttachFileName().size() > 0) {
List fl = forum.getAttachFileName();
String filePath = BBSCSUtil.getUpFilePath(forum.getBoardID(), forum.getPostTime());
for (int i = 0; i < fl.size(); i++) {
File attachFile = new File(filePath + (String) fl.get(i));
if (attachFile.exists()) {
FileUtils.forceDelete(attachFile);
}
File attachFileSmall = new File(filePath + (String) fl.get(i) + Constant.IMG_SMALL_FILEPREFIX);
if (attachFileSmall.exists()) {
FileUtils.forceDelete(attachFileSmall);
}
}
}
this.getForumDAO().removeForum(forum);
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
public void delPostsReal(List ids) throws BbscsException {
List forums = this.getForumDAO().findForumsInIds(ids);
for (int i = 0; i < forums.size(); i++) {
Forum forum = (Forum) forums.get(i);
if ( (System.currentTimeMillis() - forum.getDelTime()) > 7 * 24 * 3600 * 1000) {
try {
if (forum.getHaveAttachFile() == 1 && forum.getAttachFileName() != null &&
forum.getAttachFileName().size() > 0) {
List fl = forum.getAttachFileName();
String filePath = BBSCSUtil.getUpFilePath(forum.getBoardID(), forum.getPostTime());
for (int j = 0; j < fl.size(); j++) {
File attachFile = new File(filePath + (String) fl.get(j));
if (attachFile.exists()) {
FileUtils.forceDelete(attachFile);
}
File attachFileSmall = new File(filePath + (String) fl.get(j) + Constant.IMG_SMALL_FILEPREFIX);
if (attachFileSmall.exists()) {
FileUtils.forceDelete(attachFileSmall);
}
}
}
this.getForumDAO().removeForum(forum);
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
}
public void delWastePost(long bid) throws BbscsException {
long atime = System.currentTimeMillis() - 7 * 24 * 3600 * 1000;
List forums = this.getForumDAO().findForumsRealDelAll(bid, atime);
for (int i = 0; i < forums.size(); i++) {
Forum forum = (Forum) forums.get(i);
try {
if (forum.getHaveAttachFile() == 1 && forum.getAttachFileName() != null &&
forum.getAttachFileName().size() > 0) {
List fl = forum.getAttachFileName();
String filePath = BBSCSUtil.getUpFilePath(forum.getBoardID(), forum.getPostTime());
for (int j = 0; j < fl.size(); j++) {
File attachFile = new File(filePath + (String) fl.get(j));
if (attachFile.exists()) {
FileUtils.forceDelete(attachFile);
}
File attachFileSmall = new File(filePath + (String) fl.get(j) + Constant.IMG_SMALL_FILEPREFIX);
if (attachFileSmall.exists()) {
FileUtils.forceDelete(attachFileSmall);
}
}
}
this.getForumDAO().removeForum(forum);
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
public PageList findForumsAllManage(long bid, Pages pages) {
OrderObj oo0 = new OrderObj("postTime", Constant.ORDER_DESC);
OrderObj[] oo = {oo0};
return this.findForums(bid, -1, 0, 0, oo, pages);
}
public PageList findForumsAllManage(List bids, Pages pages) {
OrderObj oo0 = new OrderObj("postTime", Constant.ORDER_DESC);
OrderObj[] oo = {oo0};
return this.findForumsInBids(bids, -1, 0, 0, oo, pages);
}
public void saveForumsResume(List ids, Board board) throws BbscsException {
List forums = this.getForumDAO().findForumsInIds(ids);
for (int i = 0; i < forums.size(); i++) {
Forum forum = (Forum) forums.get(i);
forum.setDelSign(0);
if (forum.getIndexStatus() == Constant.INDEX_STATUS_NO_INDEX_TO_DEL) {
forum.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
}
else if (forum.getIndexStatus() == Constant.INDEX_STATUS_DELED) {
forum.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
}
try {
this.getForumDAO().saveForum(forum);
if (!forum.getId().equals(forum.getMainID())) {
Forum mainForum = this.getForumDAO().findForumByID(forum.getMainID(), forum.getBoardID());
if (mainForum != null) {
mainForum.setReNum(mainForum.getReNum() + 1);
this.getForumDAO().saveForum(mainForum);
}
}
if (board.getAddUserPostNum() == 1) {
UserInfo ui = this.getUserInfoDAO().findUserInfoById(forum.getUserID());
if (ui != null) {
ui.setArticleNum(ui.getArticleNum() + 1);
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
}
}
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
public void saveForumsAuditing(List ids, Board board) throws BbscsException {
List forums = this.getForumDAO().findForumsInIds(ids);
for (int i = 0; i < forums.size(); i++) {
Forum forum = (Forum) forums.get(i);
forum.setAuditing(0);
if (forum.getIndexStatus() == Constant.INDEX_STATUS_AUDIT) {
forum.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
}
try {
this.getForumDAO().saveForum(forum);
if (!forum.getId().equals(forum.getMainID())) {
Forum mainForum = this.getForumDAO().findForumByID(forum.getMainID(), forum.getBoardID());
if (mainForum != null) {
mainForum.setReNum(mainForum.getReNum() + 1);
this.getForumDAO().saveForum(mainForum);
}
}
if (board.getAddUserPostNum() == 1) {
UserInfo ui = this.getUserInfoDAO().findUserInfoById(forum.getUserID());
if (ui != null) {
ui.setArticleNum(ui.getArticleNum() + 1);
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
}
}
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
public void saveForumsAuditingAttachFile(List ids) throws BbscsException {
List forums = this.getForumDAO().findForumsInIds(ids);
for (int i = 0; i < forums.size(); i++) {
Forum forum = (Forum) forums.get(i);
forum.setAuditingAttachFile(0);
try {
this.getForumDAO().saveForum(forum);
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
}
public int getForumsAuditingAttachFileNum(long bid) {
return this.getForumDAO().getForumNum(bid, -1, 0, -1, 1);
}
public PageList findForumsAuditingAttachFile(long bid, Pages pages) {
OrderObj oo0 = new OrderObj("postTime", Constant.ORDER_DESC);
OrderObj[] oo = {oo0};
return this.findForums(bid, -1, 0, -1, 1, oo, pages);
}
public List findForumsTopicAuditingAttachFile(long bid, String mainID) {
OrderObj oo0 = new OrderObj("postTime", Constant.ORDER_ASC);
OrderObj[] oo = {oo0};
return this.getForumDAO().findForumsTopic(bid, mainID, 0, -1, 1, oo);
}
public void saveForumChangeUser(Forum forum, int[] titleType, int[] values) throws BbscsException {
try {
forum = this.getForumDAO().saveForum(forum);
if (titleType != null && values != null && titleType.length == values.length) {
UserInfo ui = this.getUserInfoDAO().findUserInfoById(forum.getUserID());
if (ui != null) {
for (int i = 0; i < titleType.length; i++) {
switch (titleType[i]) {
case 0:
ui.setExperience(ui.getExperience() + values[i]);
case 1:
ui.setLiterary(ui.getLiterary() + values[i]);
case 2:
ui.setUserKnow(ui.getUserKnow() + values[i]);
case 3:
ui.setCoin(ui.getCoin() + values[i]);
default:
ui.setExperience(ui.getExperience() + values[i]);
}
}
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
}
}
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
public void saveForumChangeUser(Forum forum, int titleType, int values) throws BbscsException {
try {
forum = this.getForumDAO().saveForum(forum);
UserInfo ui = this.getUserInfoDAO().findUserInfoById(forum.getUserID());
if (ui != null) {
switch (titleType) {
case 0:
ui.setExperience(ui.getExperience() + values);
case 1:
ui.setLiterary(ui.getLiterary() + values);
case 2:
ui.setUserKnow(ui.getUserKnow() + values);
case 3:
ui.setCoin(ui.getCoin() + values);
default:
ui.setExperience(ui.getExperience() + values);
}
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
}
}
catch (Exception ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
public void createCommendPage(long commend) throws BbscsException {
StringBuffer sb = new StringBuffer();
List l = this.getForumDAO().findForumsCommend(commend, "postTime", Constant.ORDER_DESC, 0, 10);
for (int i = 0; i < l.size(); i++) {
Forum f = (Forum) l.get(i);
sb.append("·");
sb.append("<a href=\"");
sb.append(BBSCSUtil.getActionMappingURLWithoutPrefix("read?action=topic&id=" + f.getMainID() + "&bid=" +
f.getBoardID()));
sb.append("\">");
sb.append(TagUtils.getInstance().filter(f.getTitle()));
sb.append("</a><BR/>");
}
File commendFile = new File(BBSCSUtil.getIncludePath() + "Commend_" + commend + ".html");
try {
FileUtils.writeStringToFile(commendFile, sb.toString(), Constant.CHARSET);
}
catch (IOException ex) {
logger.error(ex);
throw new BbscsException(ex);
}
}
public void saveForumCommend(int createOrDel, Board board, Forum f) throws BbscsException {
long topbid = board.getTopBid();
if (createOrDel == 0) {
if (f.getCommend() == 0) {
try {
f.setCommend(topbid);
f = this.getForumDAO().saveForum(f);
UserInfo ui = this.getUserInfoDAO().findUserInfoById(f.getUserID());
ui.setLiterary(ui.getLiterary() + 1);
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
Commend commend = this.getCommendDAO().findCommendByPostID(f.getId());
if (commend == null) {
commend = new Commend();
commend.setBoardCategory("");
commend.setBoardID(board.getId().longValue());
commend.setBoardName(board.getBoardName());
commend.setCommendBoardID(topbid);
commend.setCommendTop(0);
commend.setCreateTime(System.currentTimeMillis());
commend.setPostID(f.getId());
commend.setPostMainID(f.getMainID());
commend.setTitle(f.getTitle());
commend.setTopCategory("");
commend.setUserID(f.getUserID());
commend.setUserName(f.getUserName());
this.getCommendDAO().saveCommend(commend);
}
List commendList = this.getCommendDAO().findCommendsByCommendBoardID(topbid, 0, 10);
this.getCommendFileIO().saveCommendInReadPageFile(topbid, commendList);
}
catch (Exception ex1) {
logger.error(ex1);
throw new BbscsException(ex1);
}
}
}
else {
if (f.getCommend() != 0) {
try {
f.setCommend(0);
f = this.getForumDAO().saveForum(f);
UserInfo ui = this.getUserInfoDAO().findUserInfoById(f.getUserID());
ui.setLiterary(ui.getLiterary() - 1);
ui = this.getUserInfoDAO().saveUserInfo(ui);
this.getUserInfoFileIO().writeUserFile(ui);
this.getCommendDAO().removeCommend(f.getId());
List commendList = this.getCommendDAO().findCommendsByCommendBoardID(topbid, 0, 10);
this.getCommendFileIO().saveCommendInReadPageFile(topbid, commendList);
}
catch (Exception ex2) {
logger.error(ex2);
throw new BbscsException(ex2);
}
}
}
}
public List findForumsAllNew(int num) {
return this.getForumDAO().findForums( -1, 1, 0, 0, "postTime", Constant.ORDER_DESC, 0, num);
}
public List findForumsByIndexStatus(int indexStatus) {
return this.getForumDAO().findForumsByIndexStatus(indexStatus);
}
public ForumDAO getForumDAO() {
return forumDAO;
}
public UserInfoDAO getUserI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -