package com.ntsky.bbs.web.webwork.action.view;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ntsky.bbs.Symbols;
import com.ntsky.bbs.util.memory.ForumSingleton;
import com.ntsky.bbs.domain.User;
import com.ntsky.bbs.exception.ActionException;
import com.ntsky.bbs.exception.ServiceException;
import com.ntsky.bbs.util.config.SystemConfig;

/**
 * 论坛首页
 *  
 * @author ntsky
 * @link www.ntsky.com
 * 
 * @version $Revision: 1.8 $ $Date: 2007/04/01 17:18:24 $
 */
public class IndexAction extends ViewActionSupport{
	
	private List forums;
	public List getForums(){
		return forums;
	}
	
	// 首页数据
	private Map indexMap;
	public Map getIndexMap(){
		return indexMap;
	}
	
	// 最新注册的用户
	private User newlyUser;
	public User getNewlyUser(){
		return newlyUser;
	}
	
	/**
	 * 访问首页
	 * 
	 */
	public String execute() throws Exception {

		if(logger.isInfoEnabled()){
			logger.info("返回到首页...");
		}
		// 论坛数据
		forums = ForumSingleton.getInstance().getIndexForums();
		
		// 其它数据
		indexMap = new HashMap();
		indexMap.put("countUser",String.valueOf(userService.countUser()));
		indexMap.put("countTopic",String.valueOf(topicService.countTopic()));
		indexMap.put("countPost",String.valueOf(postService.countPost()));
		
		// 最新注册的用户
		newlyUser = userService.getNewlyUser();

		return SUCCESS;
	}
	
}
