首页>代码>介绍一款国内java免费开源CMS系统框架--师说CMS>/CMS/src/main/java/com/shishuo/cms/action/ArticleAction.java
/*
 *	Copyright © 2013 Changsha Shishuo Network Technology Co., Ltd. All rights reserved.
 *	长沙市师说网络科技有限公司 版权所有
 *	http://www.shishuo.com
 */

package com.shishuo.cms.action;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.shishuo.cms.entity.Article;
import com.shishuo.cms.entity.Folder;
import com.shishuo.cms.exception.ArticleNotFoundException;
import com.shishuo.cms.exception.FolderNotFoundException;
import com.shishuo.cms.exception.TemplateNotFoundException;

/**
 * @author Herbert
 * 
 */
@Controller
public class ArticleAction extends BaseAction {

	/**
	 * 一级目录页
	 * 
	 * @param ename
	 * @param pageNum
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/{firstFolderEname}/{articleId}.htm", method = RequestMethod.GET)
	public String firstFolder(@PathVariable String firstFolderEname,
			@PathVariable long articleId,
			@RequestParam(value = "p", defaultValue = "1") long p,
			ModelMap modelMap) {
		return fourthFolder(firstFolderEname, null, null, null, articleId, p,
				modelMap);
	}

	/**
	 * 二级目录页
	 * 
	 * @param ename
	 * @param pageNum
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/{firstFolderEname}/{secondFolderEname}/{articleId}.htm", method = RequestMethod.GET)
	public String secondFolder(@PathVariable String firstFolderEname,
			@PathVariable String secondFolderEname, @PathVariable long articleId,
			@RequestParam(value = "p", defaultValue = "1") long p,
			ModelMap modelMap) {
		return fourthFolder(firstFolderEname, secondFolderEname, null, null,
				articleId, p, modelMap);
	}

	/**
	 * 三级目录页
	 * 
	 * @param ename
	 * @param pageNum
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/{firstFolderEname}/{secondFolderEname}/{thirdFolderEname}/{articleId}.htm", method = RequestMethod.GET)
	public String thirdFolder(@PathVariable String firstFolderEname,
			@PathVariable String secondFolderEname,
			@PathVariable String thirdFolderEname, @PathVariable long articleId,
			@RequestParam(value = "p", defaultValue = "1") long p,
			ModelMap modelMap) {
		return fourthFolder(firstFolderEname, secondFolderEname,
				thirdFolderEname, null, articleId, p, modelMap);
	}

	/**
	 * 四级目录页
	 * 
	 * @param ename
	 * @param pageNum
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/{firstFolderEname}/{secondFolderEname}/{thirdFolderEname}/{fourthFolderEname}/{articleId}.htm", method = RequestMethod.GET)
	public String fourthFolder(@PathVariable String firstFolderEname,
			@PathVariable String secondFolderEname,
			@PathVariable String thirdFolderEname,
			@PathVariable String fourthFolderEname, @PathVariable long articleId,
			@RequestParam(value = "p", defaultValue = "1") long p,
			ModelMap modelMap) {
		try {
			List<Folder> folderPathList = packageFolderByEname(
					firstFolderEname, secondFolderEname, thirdFolderEname,
					fourthFolderEname, modelMap);
			Article article = fileService.getArticleByArticleId(articleId);
			modelMap.addAttribute("p", p);
			modelMap.addAttribute("article", article);
			return themeService.getArticleTemplate(folderPathList, articleId);
		} catch (FolderNotFoundException e) {
			logger.fatal(e.getMessage());
			return themeService.getTemplatePath("404");
		} catch (TemplateNotFoundException e) {
			logger.fatal(e.getMessage());
			return themeService.getTemplatePath("404");
		} catch (ArticleNotFoundException e) {
			logger.fatal(e.getMessage());
			return themeService.getTemplatePath("404");
		}
	}
}
最近下载更多
wjh007  LV5 2024年12月17日
辛利伟  LV7 2023年3月2日
qiang123  LV8 2022年7月8日
wanglinddad  LV55 2022年4月27日
wzp1314  LV4 2020年11月10日
oushao  LV10 2020年10月13日
hahaenenene  LV8 2020年9月2日
wcz1234  LV4 2020年3月8日
sweetyy  LV8 2019年12月24日
wangdongtai  LV31 2019年10月7日
最近浏览更多
fujinjava  LV2 3月3日
wjh007  LV5 2024年12月17日
微信网友_7212830140796928 2024年10月16日
暂无贡献等级
pengkui  LV14 2024年8月16日
是数据库  LV3 2024年5月7日
jhyan127 2024年2月18日
暂无贡献等级
PSSDZH  LV3 2024年1月25日
locklock  LV2 2023年12月22日
ninanlin  LV2 2023年10月31日
zdmxjxj  LV11 2023年9月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友