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

📄 messageaction.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.Message;
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.IPageList;

public class MessageAction extends BaseAction {
	public Object doBefore(WebForm form, Module module) {
		//系统后台,添加/删除/修改
		if("".equals(this.getCommand())||"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);
	}	
	public Page doPost(WebForm form, Module module) {	
		Message obj=(Message)form2Obj(form);
		obj.setStatus(new Integer(0));
		obj.setInputTime(new Date());
		obj.setIp(ActionContext.getContext().getRequest().getRemoteAddr());
		String url="/guestbook.htm";
		if(obj.getTitle()!=null && obj.getBelongUser()!=null && obj.getContent()!=null)
		{
		obj.save();		
		//if("leaderMail".equals(obj.getBelongUser()))url="/news/leaderMail.htm";
		form.addResult("msg","<br>  感谢您的留言,我们将会及时处理,系统将转入留言板首页!");
		}
		else
		{
		form.addResult("msg","操作失败,信息标题,内容不能为空!");
		}
		form.addResult("time","1");
		form.addResult("url",url);		
		return new Page("postOk","/news/postOk.htm","template");
	}
	public Page doShow(WebForm form, Module module) {	
		Message obj=(Message)form2Obj(form);
		form.addResult("obj",obj);
		obj.setReadTimes(new Integer(obj.getReadTimes().intValue()+1));
		obj.update();
		return  module.findPage("show");
	}
	public Page doShowLeaderMail(WebForm form, Module module) {	
		Message obj=(Message)form2Obj(form);
		form.addPo(obj);
		return  module.findPage("leaderMailShow");
	}
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) {		
		String belongUser=CommUtil.null2String(form.get("belongUser"));
		String scope="1=1";
		Collection paras=new ArrayList();	
		if(!belongUser.equals(""))
		{
			scope+=" and belongUser=?";
			paras.add(belongUser);
		}
		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(Message.class,scope,paras);
		pList.doList(currentPage,pageSize);
		return pList;
	}
	public Object form2Obj(WebForm form) {
		String cid=CommUtil.null2String(form.get("cid"));
		Message obj=null;
		if(cid.equals(""))
		{
			obj=(Message)form.toPo(Message.class);			
			//obj.setInputUser(this.getCurrentUser(form).getUserName());
			obj.setStatus(new Integer(0));
		}
		else
		{
			obj=Message.read(cid);
			form.toPo(obj);
			
		}	
		if(obj!=null && obj.getReplyContent()!=null && (!obj.getReplyContent().equals("")))
		{
		    if(obj.getPublish()!=null && obj.getPublish().intValue()==1)obj.setStatus(new Integer(2));
		    else obj.setStatus(new Integer(1));		    
			obj.setReplyTime(new Date());
			obj.setReplyUser(this.getCurrentUser(form).getUserName());
		}
		return obj;
	}
	public void doAfter(WebForm form, Module module) {		
		super.doAfter(form, module);
		String belongUser=CommUtil.null2String(form.get("belongUser"));
		String tagImg="/images/NotePad.jpg";
		String tagName="留言板";
		if(belongUser.equals("leader"))
			{tagImg="/images/Write_01.jpg";
			tagName="局长信箱";
			}
		form.addResult("tagImg",tagImg);		
		form.addResult("tagName",tagName);
		String command=this.getCommand();
		if("edit".equals(command) || "new".equals(command))
		{
			form.addResult("statusOptions",CommUtil.getSelectOptions(Message.statusTitle,""+form.get("status")));
			if("1".equals(""+form.get("publish")))form.addResult("isPublish","true");
		}
	}	

}

⌨️ 快捷键说明

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