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

📄 reviewaction.java

📁 EasyJF官网(www.easyjf.com)全站系统源码使用说明 全站源码是EasyJF开源团队站务组及核心成员共同开发及维护的系统
💻 JAVA
字号:
package com.easyjf.news.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import com.easyjf.news.business.NewsDoc;
import com.easyjf.news.business.NewsReview;
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.DbPageList;
import com.easyjf.web.tools.IActiveUser;
import com.easyjf.web.tools.IPageList;

public class ReviewAction extends BaseAction {
	public Page doShow(WebForm form, Module module) {	
		String cid=CommUtil.null2String(form.get("cid"));
		NewsDoc doc=NewsDoc.read(cid);
		if(doc!=null)
		{
			int currentPage=CommUtil.null2Int(form.get("page"));
			int pageSize=CommUtil.null2Int(form.get("pageSize"));
			if(currentPage<1)currentPage=1;
			if(pageSize<1)pageSize=15;
			String scope="parent=?";
			Collection paras=new ArrayList();	
			paras.add(doc.getCid());
			scope +=" order by inputTime asc";
			DbPageList pList=new DbPageList(NewsReview.class,scope,paras);
			pList.doList(currentPage,pageSize);
			CommUtil.saveIPageList2WebForm(pList,form);
			if(pList!=null)form.addResult("pageSize",new Integer(pageSize));			
			form.addPo(doc);
			IActiveUser user=this.getCurrentUser(form);
			if(user!=null)form.addResult("myUserName",user.getUserName());
			form.addResult("staticUrl",doc.htmlUrl());
		}		
		return module.findPage("show");
	}
	public Page doPost(WebForm form, Module module) {	
		NewsReview obj=(NewsReview)form2Obj(form);		
		obj.setInputTime(new Date());
		obj.setIp(ActionContext.getContext().getRequest().getRemoteAddr());
		String url="/review.ejf?easyJWebCommand=show&cid="+obj.getParent();
		if(obj.getInputUser()!=null && obj.getContent()!=null)
		{
		obj.save();
		form.addResult("msg","<br>  感谢您的评论,系统将转入评论页面!");
		}
		else
		{
		form.addResult("msg","操作失败,信息标题,内容不能为空!");
		}
		form.addResult("time","1");
		form.addResult("url",url);		
		return new Page("postOk",url,"html");
	}
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) {		
		String parent=CommUtil.null2String(form.get("parent"));
		String scope="1=1";
		Collection paras=new ArrayList();	
		if(!parent.equals(""))
		{
			scope+=" and parent=?";
			paras.add(parent);
		}
		String orderType=CommUtil.null2String(form.get("orderType"));
		String orderField=CommUtil.null2String(form.get("orderField"));			
		if(orderField.equals(""))
		{
		orderField="inputTime";
		orderType="desc";				
		}	
		if(!orderField.equals(""))
		{
		scope +=" order by "+orderField;
		if(!orderType.equals(""))scope+=" "+orderType;
		}
		DbPageList pList=new DbPageList(NewsReview.class,scope,paras);
		pList.doList(currentPage,pageSize);
		return pList;
	}
	public Object form2Obj(WebForm form) {
		String cid=CommUtil.null2String(form.get("cid"));
		NewsReview obj=null;
		if(cid.equals(""))
		{
			obj=(NewsReview)form.toPo(NewsReview.class);
		}
		else
		{
			obj=NewsReview.read(cid);
			form.toPo(obj);			
		}			
		return obj;
	}	
	public Object doBefore(WebForm form, Module module) {
		//系统后台,添加/删除/修改
		if("edit".equals(this.getCommand())|| "save".equals(this.getCommand()) || "update".equals(this.getCommand())|| "del".equals(this.getCommand()))
		{
			if(this.getCurrentUser(form)==null){
			form.addResult("msg","您没有登录,或者登录信息已经超时,请重新登录!");
			return new Page("popedomError","/nologin.htm","page");
			}
		}		
		return super.doBefore(form,module);
	}
}

⌨️ 快捷键说明

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