Пример #1
0
 @RequestMapping("/keyword/{con}")
 public String keyword(@PathVariable String con, Model model) {
   model.addAttribute("kws", keywordService.getMaxTimesKeyword(9));
   SystemContext.setOrder("desc");
   SystemContext.setSort("t.publishDate");
   Pager<Topic> topics = topicService.searchTopicByKeyword(con);
   emp(topics, con);
   model.addAttribute("datas", topics);
   model.addAttribute("con", con);
   return "index/keyword";
 }
Пример #2
0
 @RequestMapping("/search/{con}")
 public String search(@PathVariable String con, Model model) {
   SystemContext.setOrder("asc");
   SystemContext.setSort("c.orders");
   model.addAttribute("cs", channelService.listChannelByType(ChannelType.NAV_CHANNEL));
   SystemContext.setOrder("desc");
   SystemContext.setSort("t.publishDate");
   Pager<Topic> topics = topicService.searchTopic(con);
   emp(topics, con);
   model.addAttribute("datas", topics);
   model.addAttribute("con", con);
   return "index/search";
 }
Пример #3
0
 @Override
 public void generateBody() {
   System.out.println("=========重新生成首页的内容信息==============");
   // 1、获取所有的首页栏目
   List<Channel> cs = channelService.listAllIndexChannel(ChannelType.TOPIC_LIST);
   // 2、根据首页栏目创建相应的IndexTopic对象
   // 加载indexChannel.properties
   Properties prop = PropertiesUtil.getInstance().load("indexChannel");
   // 文章 第一个是次序,用来在ftl中显示次序ts[1] order 是在配置文件中配置的
   Map<String, IndexTopic> topics = new HashMap<String, IndexTopic>();
   for (Channel c : cs) {
     int cid = c.getId();
     String[] xs = prop.getProperty(cid + "").split("_"); //
     String order = xs[0];
     int num = Integer.parseInt(xs[1]); // num 显示的数目
     IndexTopic it = new IndexTopic();
     it.setCid(cid);
     it.setCname(c.getName());
     List<Topic> tops = topicService.listTopicByChannelAndNumber(cid, num);
     //			System.out.println(cid+"--"+tops);
     it.setTopics(tops);
     topics.put(order, it);
   }
   String outfile = SystemContext.getRealPath() + outPath + "/body.jsp";
   // 3、更新首页图片
   BaseInfo bi = BaseInfoUtil.getInstacne().read();
   int picnum = bi.getIndexPicNumber();
   Map<String, Object> root = new HashMap<String, Object>();
   root.put("ts", topics);
   root.put("pics", indexPicService.listIndexPicByNum(picnum));
   root.put("keywords", keyworkService.getMaxTimesKeyword(12));
   root.put("xxgk", topicService.loadLastedTopicByColumn(7));
   util.fprint(root, "/body.ftl", outfile);
 }
Пример #4
0
 @Override
 public void generateBottom() {
   System.out.println("=============重新生成了底部信息====================");
   Map<String, Object> root = new HashMap<String, Object>();
   root.put("baseInfo", BaseInfoUtil.getInstacne().read());
   String outfile = SystemContext.getRealPath() + outPath + "/bottom.jsp";
   util.fprint(root, "/bottom.ftl", outfile);
 }
Пример #5
0
 @Override
 public void generateTop() {
   System.out.println("=============重新生成了顶部信息====================");
   List<Channel> cs = channelService.listTopNavChannel();
   Map<String, Object> root = new HashMap<String, Object>();
   root.put("navs", cs);
   root.put("baseInfo", BaseInfoUtil.getInstacne().read());
   String outfile = SystemContext.getRealPath() + outPath + "/top.jsp";
   util.fprint(root, "/top.ftl", outfile);
 }
Пример #6
0
 @RequestMapping("/channel/{cid}")
 public String showChannel(
     @PathVariable int cid, Model model, HttpServletResponse resp, HttpServletRequest req)
     throws IOException {
   Channel c = channelService.load(cid);
   System.out.println(c.getType());
   Channel pc = null;
   if (c.getType() == ChannelType.NAV_CHANNEL) {
     pc = c;
     // 如果是导航栏目,需要获取该栏目中的第一个栏目
     c = channelService.loadFirstChannelByNav(c.getId());
   } else {
     pc = c.getParent();
   }
   //		System.out.println(c.getType()==ChannelType.TOPIC_LIST);
   //		System.out.println(c.getType());
   if (c.getType() == ChannelType.TOPIC_CONTENT) {
     resp.sendRedirect(
         req.getContextPath() + "/topic/" + topicService.loadLastedTopicByColumn(cid).getId());
   } else if (c.getType() == ChannelType.TOPIC_IMG) {
     SystemContext.setPageSize(16);
     SystemContext.setSort("a.topic.publishDate");
     SystemContext.setOrder("desc");
     Pager<Attachment> atts = attachmentService.findChannelPic(cid);
     model.addAttribute("datas", atts);
   } else if (c.getType() == ChannelType.TOPIC_LIST) {
     SystemContext.setSort("t.publishDate");
     SystemContext.setOrder("desc");
     // System.out.println(c.getType());
     model.addAttribute("datas", topicService.find(c.getId(), null, 1));
   }
   SystemContext.removeSort();
   SystemContext.removeOrder();
   model.addAttribute("pc", pc);
   model.addAttribute("cs", channelService.listUseChannelByParent(pc.getId()));
   model.addAttribute("channel", c);
   if (c.getType() == ChannelType.TOPIC_LIST) {
     return "index/channel";
   } else {
     return "index/channel_pic";
   }
 }