⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collectionsaction.java

📁 简易java框架开源论坛系统,简 易java框架开源论坛系统
💻 JAVA
字号:
package com.easyjf.bbs.action;

import com.easyjf.bbs.business.ActiveUser;
import com.easyjf.bbs.business.BBSRights;
import com.easyjf.bbs.business.Collections;
import com.easyjf.bbs.business.Friend;
import com.easyjf.bbs.business.UserInfo;
import com.easyjf.bbs.business.util.CollectionsUtil;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
import com.easyjf.web.tools.IPageList;

public class CollectionsAction extends AbstractCmdAction {

	public CollectionsAction() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Page doInit(WebForm form, Module module) {
		// TODO Auto-generated method stub
		return null;
	}

	public ActiveUser getCurrentUser() {
		ActiveUser user = (ActiveUser) ActionContext.getContext().getSession()
				.getAttribute("bbsuser");
		return user;
	}

	public Page doList(WebForm form, Module module) {
		if (!BBSRights.checkRights(new Collections(), "list", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		return doQuery(form, module);
	}

	public Page doQuery(WebForm form, Module module) {
		int currentPage = CommUtil.null2Int(form.get("page"));
		int pageSize = CommUtil.null2Int(form.get("pageSize"));
		if (currentPage < 1)
			currentPage = 1;
		if (pageSize < 1)
			pageSize = 15;
		IPageList pList = CollectionsUtil.queryCollections("cid in (select docid from collections where ownername ='"+getCurrentUser().getUserName()+"')", pageSize, currentPage);
		if (pList != null) {
			form.addResult("list", pList.getResult());
			form.addResult("pages", new Integer(pList.getPages()));
			form.addResult("rows", new Integer(pList.getRowCount()));
			form.addResult("page", new Integer(pList.getCurrentPage()));
			form.addResult("gotoPageHTML", CommUtil.showPageHtml(pList
					.getCurrentPage(), pList.getPages()));
		}
		form.addResult("ownername",getCurrentUser().getUserName());
		return module.findPage("list");
	}
	
	public Page doAdd(WebForm form,Module module){
		if (!BBSRights.checkRights(new Collections(), "add", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		String docid=CommUtil.null2String(form.get("docid"));
		String owner=getCurrentUser().getUserName();
		if(docid!=null&&owner!=null){
			Collections c=new Collections();
			c.setDocid(docid);
			c.setOwnername(owner);
			c.save();
		}
		return new Page("CollectionsList",
				"/bbscollections.ejf?easyJWebCommand=list", "page");
	}
	
	public Page doDel(WebForm form,Module module){
		if (!BBSRights.checkRights(new Collections(), "list", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		String docid=CommUtil.null2String(form.get("cid"));
		String ownername=CommUtil.null2String(form.get("ownername"));
		if(docid!=null&&ownername!=null){
			Collections c=Collections.readByDocUser(docid,ownername);
			c.del();
		}
		return new Page("CollectionsList",
				"/bbscollections.ejf?easyJWebCommand=list", "page");
	}
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -