mainjsp.java

来自「野蔷薇论坛源码 java 自己看看吧。 学习用」· Java 代码 · 共 86 行

JAVA
86
字号
/* 
 * Created on 2007-5-13
 * Last modified on 2007-6-12
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.view.jsp;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yeqiangwei.club.param.TopicParameter;
import com.yeqiangwei.club.service.ServiceLocator;
import com.yeqiangwei.club.service.ServiceWrapper;
import com.yeqiangwei.club.service.counter.CountService;
import com.yeqiangwei.club.service.forum.ForumService;
import com.yeqiangwei.club.service.model.CountersModel;
import com.yeqiangwei.club.service.model.ForumModel;
import com.yeqiangwei.club.service.model.TopicModel;
import com.yeqiangwei.club.service.topic.TopicService;
import com.yeqiangwei.club.util.BeanLocator;
import com.yeqiangwei.club.util.BeanUtils;
import com.yeqiangwei.club.view.model.CounterView;
import com.yeqiangwei.club.view.model.ForumView;
import com.yeqiangwei.club.view.model.TopicView;
import com.yeqiangwei.util.Validator;

public class MainJsp extends BaseJsp{

	public MainJsp(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
	}
	
	public List<ForumView> findTopForums(int rows){
		List<ForumModel> mlist = this.getForumService().findTops(rows);
		List<ForumView> list = BeanUtils.copyList(mlist,BeanLocator.FORUMVIEW);
		return list;
	}
	
	public List<TopicView> findOrderBy(int rows, byte orderBy){
		TopicParameter param = new TopicParameter();
		param.setForumId(null);
		param.setPage(1);
		param.setRows(rows);
		param.setOrderBy(orderBy); //order by topicId desc
		param.setIsDeleted(new Boolean(false));
		List<TopicModel> mlist = this.getTopicService().findByParameter(param);
		List<TopicView> list = BeanUtils.copyList(mlist,BeanLocator.TOPICVIEW);
		return list;
	}
	
	public List<TopicView> findTopic(int rows){
		return this.findOrderBy(rows,(byte)2);
	}

	public List<TopicView> findOrderByTopicId(int rows){
		return this.findOrderBy(rows,(byte)2);
	}
	
	public List<TopicView> findOrderByReplyId(int rows){
		return this.findOrderBy(rows,(byte)3);
	}

	public CounterView getCounterView(){
		CounterView v = new CounterView();
		CountersModel m = this.getCountService().findOnlyPublic();
		if(!Validator.isEmpty(m)){
			BeanUtils.copyProperties(v,m);
		}
		return v;
	}
	
	private CountService getCountService() {
		return ServiceWrapper.<CountService>getSingletonInstance(ServiceLocator.COUNT);
	}
	
	private ForumService getForumService() {
		return ServiceWrapper.<ForumService>getSingletonInstance(ServiceLocator.FORUM);
	}
	
	public TopicService getTopicService() {
		return ServiceWrapper.<TopicService>getSingletonInstance(ServiceLocator.TOPIC);
	}
}

⌨️ 快捷键说明

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