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

📄 filterwordsaction.java

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

import java.util.Iterator;

import com.easyjf.bbs.business.ActiveUser;
import com.easyjf.bbs.business.BBSRights;
import com.easyjf.bbs.business.BBSUtil;
import com.easyjf.bbs.business.FilterWords;
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 FilterWordsAction extends AbstractCmdAction {

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

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

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

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

	public Page doPreAdd(WebForm form,Module module){
		return module.findPage("save");
	}
	
	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 = BBSUtil.queryWords("1=1", 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()));
		}
		return module.findPage("list");
	}

	public Page doAdd(WebForm form, Module module) {
		if (!BBSRights.checkRights(new FilterWords(), "add", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		String banwords = CommUtil.null2String(form.get("banword"));
		if (BBSUtil.isDulpWord(banwords)) {
			form.addResult("msg", "重复的关键字!");
		} else {
			FilterWords fw = new FilterWords();
			fw.setWord(banwords);
			FilterWords.save(fw);
			form.addResult("msg", "添加成功!");
		}
		return new Page("FilterWordsList",
				"/bbsfilter.ejf?easyJWebCommand=list", "page");
	}

	public Page doUpdata(WebForm form, Module module) {
		if (!BBSRights.checkRights(new FilterWords(), "add", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		String banwords = CommUtil.null2String(form.get("banword"));
		if (BBSUtil.isDulpWord(banwords)) {
			form.addResult("msg", "重复的关键字!");
		} else {
			FilterWords fw = new FilterWords();
			fw.setWord(banwords);
			fw.setId(CommUtil.null2String(form.get("cid")));
			FilterWords.updata(fw);
			form.addResult("msg", "更新成功!");
		}
		return new Page("FilterWordsList",
				"/bbsfilter.ejf?easyJWebCommand=list", "page");
	}

	public Page doEdit(WebForm form, Module module) {
		String cid = CommUtil.null2String(form.get("cid"));
		ActiveUser user = getCurrentUser();
		FilterWords obj = null;
		if (!cid.equals("")) {
			obj = FilterWords.read(cid);
		}
		if (!BBSRights.checkRights(obj, "edit", user))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		if (obj != null)
			CommUtil.Obj2Map(obj, form.getTextElement());
		return module.findPage("edit");
	}

	public Page doDel(WebForm form, Module module) {
		if (!BBSRights.checkRights(new FilterWords(), "del", getCurrentUser()))
			return new Page("popedomError", "/bbs/norights.htm", "page");
		String id = CommUtil.null2String(form.get("cid"));
		if (!"".equals(id)) {
			FilterWords fw = FilterWords.read(id);
			FilterWords.del(fw);
			form.addResult("msg", "删除成功!");
		}
		return new Page("FilterWordsList",
				"/bbsfilter.ejf?easyJWebCommand=list", "page");
	}

}

⌨️ 快捷键说明

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