@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); }
@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); }
@Autowired(required = true) public IndexService(String ftlPath, String outPath) { super(); if (util == null) { this.outPath = outPath; util = FreemarkerUtil.getInstance(ftlPath); } }
@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); }