Esempio n. 1
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);
 }
Esempio n. 2
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";
   }
 }