Example #1
0
  @RequestMapping(value = "/comiclist/{name}/{id}/{page}")
  public String ComicInfoSub(
      @PathVariable("name") String name,
      @PathVariable("id") String id,
      @PathVariable("page") String page,
      Model m) {

    String path = "";
    String pageId = name + "_" + id + "_" + page;
    ComicPart cp = comicService.GetComicPart(name, id);
    Set<ComicPage> cps = cp.getComicPages();
    if (cps.size() < Integer.parseInt(page)) pageId = name + "_" + id + "_" + cps.size();
    if (Integer.parseInt(page) <= cps.size()) {
      Iterator<ComicPage> iterator = cps.iterator();
      while (iterator.hasNext()) {
        ComicPage comicPage = iterator.next();
        if (comicPage.getPageId().equals(pageId)) {
          path = comicPage.getFilePath();
          break;
        }
      }
    }
    int pageSum = cps.size();
    m.addAttribute("page_sum", pageSum);
    m.addAttribute("page_currentPage", page);
    m.addAttribute("comicPath", path);
    return "Comic/ComicPageSub";
  }
Example #2
0
  @RequestMapping(value = "/comiclist/{name}/{id}")
  public String ComicInfoSub(
      @PathVariable("name") String name, @PathVariable("id") String id, Model m) {
    String pageId = name + "_" + id + "_" + 1;

    String[] strTmp = id.split("_");

    String path = "";

    for (int i = 0; i < strTmp.length - 1; i++) path += strTmp[i] + "_";

    int num = Integer.parseInt(strTmp[strTmp.length - 1]);
    System.out.println(num);

    int partSum = comicService.GetComicPartSum(name);

    ComicPart cp = comicService.GetComicPart(name, id);

    Set<ComicPage> cps = cp.getComicPages();
    Iterator<ComicPage> iterator = cps.iterator();
    while (iterator.hasNext()) {
      ComicPage comicPage = iterator.next();
      System.out.println("pageId:" + comicPage.getPageId());
      if (comicPage.getPageId().equals(pageId)) {
        m.addAttribute("comicPath", comicPage.getFilePath());
        break;
      }
    }

    int pageSum = cps.size();
    int pre = num <= 1 ? 1 : num - 1;
    m.addAttribute("comicPrePartId", path + pre);
    m.addAttribute("comicPrePartName", comicService.GetComicPart(name, path + pre).getPartName());

    int next = num >= partSum ? partSum : num + 1;
    m.addAttribute("comicNextPartId", path + next);
    m.addAttribute("comicNextPartName", comicService.GetComicPart(name, path + next).getPartName());

    Set<SpitSlot> spitSlots = cp.getSpitSlots();
    m.addAttribute("page_sum", pageSum);
    m.addAttribute("page_currentPage", 1);
    m.addAttribute("spitSlots", spitSlots);
    m.addAttribute("comicName", cp.getComic().getComicName());
    m.addAttribute("comicPart", cp.getPartName());
    m.addAttribute("comicPartId", cp.getPartId());
    m.addAttribute("comicId", cp.getComic().getComicId());
    return "Comic/ComicContent";
  }