Exemplo n.º 1
0
 @RequestMapping("/topic/{tid}")
 public String showTopic(@PathVariable int tid, Model model) {
   model.addAttribute("topic", topicService.load(tid));
   List<Attachment> atts = attachmentService.listAttachByTopic(tid);
   if (atts.size() > 0) {
     model.addAttribute("hasAtts", true);
     model.addAttribute("atts", atts);
   } else {
     model.addAttribute("hasAtts", false);
   }
   return "index/topic";
 }
Exemplo 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";
   }
 }