首页>代码>java lucene实现近实时搜索及高亮显示的代码例子下载>/message5_1/src/org/itat/message/action/MessageAction.java
package org.itat.message.action;

import javax.annotation.Resource;

import org.itat.message.iservice.ICommentService;
import org.itat.message.iservice.IMessageService;
import org.itat.message.util.ActionUtil;
import org.itat.message.util.PageObject;
import org.itat.message.util.SystemContext;
import org.itat.message.vo.Message;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller("messageAction")
@Scope("prototype")
public class MessageAction extends ActionSupport implements ModelDriven<Message>{
	private static final long serialVersionUID = -3266057605774486873L;
	private IMessageService messageService;
	private ICommentService commentService;
	private Message message;
	private String type;
	private String keyword;
	private int userId;
	private Integer[] myatt;
	
	

	public Message getMessage() {
		return message;
	}
	public void setMessage(Message message) {
		this.message = message;
	}
	public ICommentService getCommentService() {
		return commentService;
	}
	@Resource
	public void setCommentService(ICommentService commentService) {
		this.commentService = commentService;
	}

	public Integer[] getMyatt() {
		return myatt;
	}

	public void setMyatt(Integer[] myatt) {
		this.myatt = myatt;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public IMessageService getMessageService() {
		return messageService;
	}

	@Resource
	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}


	public String list() {
		PageObject<Message> pages = null;
		SystemContext.setSort("m.createDate");
		SystemContext.setOrder("desc");
		if("title".equals(type)) {
			pages = messageService.findByTitle(keyword);
		} else if("content".equals(type)) {
			pages = messageService.findByContent(keyword);
		} else {
			pages = messageService.findByTitle(null);
		}
		ActionContext.getContext().put("pages", pages);
		return ActionUtil.MSG_LIST;
	}


	public Message getModel() {
		if(message==null) message = new Message();
		return message;
	}
	
	public String addInput() {
		return SUCCESS;
	}
	
	public String add() {
		messageService.add(message, userId,myatt);
		ActionContext.getContext().put("urlAction", "message_list.action");
		return ActionUtil.REDIRECT;
	}
	
	public String show() {
		Message tm = messageService.load(message.getId());
		setMessage(tm);
		ActionContext.getContext().put("comments", commentService.findByMsg(message.getId()));
		return SUCCESS;
	}
}
最近下载更多
813405250  LV5 2021年1月2日
Sillage  LV3 2020年6月1日
全国12345  LV3 2020年5月17日
cbl234  LV1 2020年4月10日
shenshenya  LV2 2019年5月26日
执笔写下青春  LV12 2018年6月19日
mahuig  LV10 2018年4月18日
lindawhn  LV6 2018年4月12日
fengzf  LV16 2018年1月12日
ypf8312  LV22 2017年9月7日
最近浏览更多
zjut_ywf 2023年11月13日
暂无贡献等级
jy1218  LV12 2023年2月16日
cfdymyj 2022年10月8日
暂无贡献等级
BestClever  LV32 2022年6月15日
dongzhan  LV12 2021年12月16日
dongzhan  LV12 2021年12月16日
lirui9900  LV1 2021年11月16日
西凉河的葛三叔  LV3 2021年8月28日
shion994  LV6 2021年5月18日
lodddy  LV6 2021年5月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友