package org.yufeng.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.yufeng.domains.Article;
import org.yufeng.domains.Assort;
import org.yufeng.domains.Sort;
import org.yufeng.utils.PageService;
import org.yufeng.utils.Tools;
public class ArticleAction extends BaseAction {
// 显示文章
@SuppressWarnings("unchecked")
public ActionForward article_show(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session=request.getSession();
String ar_id=request.getParameter("ar_id");
//显示文章详细信息
Article article=this.getArticleService().loadArticle(new Integer(ar_id));
article.setAr_hits(article.getAr_hits()+1);
this.getArticleService().updateArticle(article);
//获得article类型
Sort sort=this.getSortService().loadSort(article.getAr_sort_id());
Assort assort=this.getAssortService().loadAssort(article.getAr_assort_id());
//周月排行
List article_week_list=this.getArticleService().browseArticle_Week();
List article_month_list=this.getArticleService().browseArticle_Month();
//相关文章的查询
List article_about_list =this.getArticleService().browseAboutArticle(article.getAr_name());
session.setAttribute("article", article);
session.setAttribute("sort", sort);
session.setAttribute("assort", assort);
session.setAttribute("article_week_list", article_week_list);
session.setAttribute("article_month_list", article_month_list);
session.setAttribute("article_about_list", article_about_list);
return mapping.findForward("article");
}
// 显示文章的子类别和文章,通过so_id
@SuppressWarnings("unchecked")
public ActionForward article_show_bysort(ActionMapping mapping,
ActionForm form, HttpServletRequest request,HttpServletResponse response) {
HttpSession session=request.getSession();
session.removeAttribute("search");
String so_id=request.getParameter("so_id");
List alllist=this.getArticleService().browseArticleBySo_id(new Integer(so_id));
List assort_list=this.getAssortService().browseAllAssortById(new Integer(so_id));
for (int i = 0; i < assort_list.size(); i++) {
Assort assort=(Assort) assort_list.get(i);
assort.setAs_count(this.getArticleService().browseArticleByAs_id(assort.getAs_id()).size());
}
List ar_hit_list=getArticleService().browseArticleBySoHits(new Integer(so_id));
// 设置请求分页号
PageService page=new PageService();
String pageId=request.getParameter("pageId");
List article_list=page.getPage(pageId, 10, alllist);
String footer = page.getPageFooter(request.getRequestURI(),
"article_show_bysort&so_id=" + so_id);
session.setAttribute("footer", footer);
session.setAttribute("article_list", article_list);
session.setAttribute("assort_list", assort_list);
session.setAttribute("ar_hit_list", ar_hit_list);
// 排序和查询所用参数
session.setAttribute("so_id", so_id);
session.setAttribute("as_id", "");
session.setAttribute("flag", 3);
session.setAttribute("flagg", 3);
return mapping.findForward("article_show");
}
// 显示文章的子类别和文章,通过as_id
@SuppressWarnings("unchecked")
public ActionForward article_show_byassort(ActionMapping mapping,
ActionForm form, HttpServletRequest request,HttpServletResponse response) {
HttpSession session=request.getSession();
session.removeAttribute("search");
String so_id=request.getParameter("so_id");
String as_id=request.getParameter("as_id");
List alllist=this.getArticleService().browseArticleByAs_id(new Integer(as_id));
List assort_list=this.getAssortService().browseAllAssortById(new Integer(so_id));
List ar_hit_list=this.getArticleService().browseArticleByAsHits(new Integer(as_id));
// 设置请求分页号
PageService page=new PageService();
String pageId=request.getParameter("pageId");
List article_list=page.getPage(pageId, 10, alllist);
String footer = page.getPageFooter(request.getRequestURI(),
"article_show_byassort&so_id=" + so_id + "&as_id=" + as_id);
session.setAttribute("footer", footer);
session.setAttribute("article_list", article_list);// 获得文章列表
session.setAttribute("assort_list", assort_list);// 获得子类别列表
session.setAttribute("ar_hit_list", ar_hit_list);// 热门assort排行列表
session.setAttribute("as_id", as_id);
session.setAttribute("so_id", so_id);
session.setAttribute("flag", 4);
session.setAttribute("flagg", 4);
return mapping.findForward("article_show");
}
// 推荐文章
@SuppressWarnings("unchecked")
public ActionForward article_hot(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
List article_list = (List) session.getAttribute("ar_show_list");
// 获得阅读排行信息
List ar_hit_list = getArticleService().browseArticleByHits();
session.setAttribute("flag", 1);
session.setAttribute("flagg", 1);
session.setAttribute("article_list", article_list);
session.setAttribute("ar_hit_list", ar_hit_list);
return mapping.findForward("article_show");
}
// 查找站内文章
@SuppressWarnings("unchecked")
public ActionForward article_search(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
String so_id = request.getParameter("so_id");
String search = request.getParameter("search");
// 删除session缓存
session.removeAttribute("article_list");
List ar_hits_list = null;
List alllist = null;
// 判断是否有so_id
if (so_id.equals("0")) {
alllist = getArticleService().browseArticleBysearch(0, search);
ar_hits_list = getArticleService().browseArticleByHits();
session.setAttribute("ar_hit_list", ar_hits_list);// 获得assort阅读排行
session.setAttribute("search_by", "所有分类");// 用于显示查询的作用域sort_name
} else {
alllist = getArticleService().browseArticleBysearch(
new Integer(so_id), search);
ar_hits_list = getArticleService().browseArticleBySoHits(
new Integer(so_id));// 获得子分类阅读排行
List assort_list = getAssortService().browseAllAssortById(
new Integer(so_id));// 获得子分类文章列表
session.setAttribute("ar_hit_list", ar_hits_list);
session.setAttribute("assort_list", assort_list);
Assort assort = (Assort) assort_list.get(0);
Sort sort = getSortService().loadSort(assort.getAs_sort_id()); // 用于显示查询的作用域sort_name
session.setAttribute("search_by", sort.getSo_name()); //
}
session.setAttribute("flag", 2);
session.setAttribute("flagg", 2);
session.setAttribute("so_id", so_id);
session.setAttribute("search", search);
PageService page = new PageService();
// 设置请求分页号
String pageId = request.getParameter("pageId");
List article_list = page.getPage(pageId, 10, alllist);
String footer = page.getPageFooter(request.getRequestURI(),
"article_search&so_id=" + so_id + "&search=" + search);
session.setAttribute("footer", footer);
session.setAttribute("article_list", article_list);
session.setAttribute("search", search);
return mapping.findForward("article_search");
}
// 后台查找文章
@SuppressWarnings("unchecked")
public ActionForward admin_ar_search(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
HttpSession session = request.getSession();
String search = request.getParameter("search");
List article_list = getArticleService()
.browseArticleBysearch(0, search);
Article article = null;
// 获得所有Article信息
for (int i = 0; i < article_list.size(); i++) {
article
ganminhui
- 粉丝: 0
- 资源: 21
最新资源
- 【创新无忧】基于多元宇宙优化算法MVO优化广义神经网络GRNN实现光伏预测附matlab代码.rar
- 【创新无忧】基于白鲨优化算法WSO优化广义神经网络GRNN实现光伏预测附matlab代码.rar
- 【创新无忧】基于多元宇宙优化算法MVO优化广义神经网络GRNN实现数据回归预测附matlab代码.rar
- 【创新无忧】基于多元宇宙优化算法MVO优化极限学习机ELM实现乳腺肿瘤诊断附matlab代码.rar
- 【创新无忧】基于多元宇宙优化算法MVO优化极限学习机KELM实现故障诊断附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化广义神经网络GRNN实现电机故障诊断附matlab代码.rar
- 【创新无忧】基于多元宇宙优化算法MVO优化相关向量机RVM实现数据多输入单输出回归预测附matlab代码.rar
- 【创新无忧】基于多元宇宙优化算法MVO优化相关向量机RVM实现北半球光伏数据预测附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化广义神经网络GRNN实现光伏预测附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化极限学习机ELM实现乳腺肿瘤诊断附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化广义神经网络GRNN实现数据回归预测附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化相关向量机RVM实现数据多输入单输出回归预测附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化相关向量机RVM实现北半球光伏数据预测附matlab代码.rar
- 【创新无忧】基于飞蛾扑火优化算法MFO优化极限学习机KELM实现故障诊断附matlab代码.rar
- 【创新无忧】基于非洲秃鹫优化算法AVOA优化广义神经网络GRNN实现电机故障诊断附matlab代码.rar
- 【创新无忧】基于非洲秃鹫优化算法AVOA优化广义神经网络GRNN实现光伏预测附matlab代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈