@RequestMapping(value = "/book/{bookid}", method = RequestMethod.GET)
  public String BookInfo(@PathVariable Integer bookid, Model model, HttpServletRequest request)
      throws JsonGenerationException, JsonMappingException, IOException {

    logger.info("----查看图书信息----");
    // 根据图书id获取图书信息
    Book book = bookService.selectBook(bookid);
    // 图书图书分类获取图书分类目录,,形成面包屑导航
    int classify = book.getBookclassid();
    List<Class> classlist = new ArrayList<Class>();
    Class classify2 = new Class();
    while (classify != 0) {
      classify2 = classifyService.SelectTwoClassify(classify);
      classify = classify2.getClassfatherid();
      classlist.add(classify2);
    }
    // 获取bookid和userid 判断用户之前是否已经收藏过该书
    //		 String userid=new String();
    //		 Cookie[]  cookies=  request.getCookies();
    //		 for(Cookie c:cookies){
    //			 if(c.getName().equals("userid")){
    //				 userid= c.getValue();
    //			 }
    //		 }

    User user = (User) request.getSession().getAttribute("user");
    System.out.println(user);
    if (user != null) {
      boolean valiCollect = collectService.selectCollect(bookid, user.getUserid());
      System.out.println(valiCollect);
      model.addAttribute("valiCollect", valiCollect);
    } else {
      model.addAttribute("valiCollect", null);
    }

    // 获取该书的评论
    List<CommentWapper> commentlist = commentWapperService.selectCommentByBookId(bookid);
    ObjectMapper mapper = new ObjectMapper();
    logger.info(mapper.writeValueAsString(classlist));
    // 反序
    Collections.reverse(classlist);
    logger.info(mapper.writeValueAsString(classlist));
    System.out.println("commentlist" + commentlist);
    logger.info("commentlist" + mapper.writeValueAsString(commentlist));
    model.addAttribute("classlist", classlist);
    model.addAttribute("book", book);
    model.addAttribute("commentlist", commentlist);
    return "home/book";
  }
  /**
   * @param book
   * @return
   * @throws IllegalStateException
   * @throws IOException
   * @throws JsonMappingException
   * @throws JsonGenerationException
   */
  @RequestMapping(value = "/Book/modifyBook", method = RequestMethod.POST)
  public String modifyBook2(
      @RequestParam("bookid") Integer bookid,
      @RequestParam("bookname") String bookname,
      @RequestParam("author") String author,
      @RequestParam("publish") String publish,
      @RequestParam("isbn") String isbn,
      @RequestParam("publishdate") String publishdate,
      @RequestParam("picturename") String picturename,
      @RequestParam("repertory") String repertory,
      @RequestParam("sales") Integer sales,
      @RequestParam("price") Double price,
      @RequestParam("stock") Integer stock,
      @RequestParam(value = "bookclassid", required = false) Integer bookclassid,
      @RequestParam(value = "isrecommend", required = false) String isrecommend,
      @RequestParam("intro") String intro,
      @RequestParam("picture") MultipartFile file,
      Model model)
      throws IllegalStateException, IOException {
    // 修改图片
    logger.info("POST---修改图书---");
    // 对图片进行判断,判断是否新上传了图片
    String newFileName = "";
    if (file.getOriginalFilename() != null) {
      String fileName = file.getOriginalFilename();
      logger.info("原文件名" + fileName);
      String path = "O:\\picc\\";

      if (file != null && fileName != null && fileName.length() > 0) {
        newFileName = UUID.randomUUID() + fileName.substring(fileName.lastIndexOf("."));
        File newFile = new File(path + newFileName);
        file.transferTo(newFile);

        logger.info("上传成功");
      }
    }
    // 将原本的图片名称再次赋值给新的图书
    else {
      newFileName = picturename;
    }

    Book book = new Book();
    book.setBookid(bookid);
    book.setAuthor(author);
    book.setBookclassid(bookclassid);
    book.setBookname(bookname);
    book.setIntro(intro);
    book.setIsbn(isbn);

    if (isrecommend == null) {
      isrecommend = "0";
    }
    logger.info(isrecommend);
    book.setPublishdate(publishdate);
    book.setIsrecommend(isrecommend);
    book.setPicture(newFileName);
    book.setPrice(price);
    book.setPublish(publish);
    book.setRepertory(repertory);
    book.setSales(sales);
    book.setStock(stock);
    ObjectMapper mapper = new ObjectMapper();
    System.out.println("输出修改后的book");
    logger.info(mapper.writeValueAsString(book));

    int i = bookService.updateBook(book);
    System.out.println(i);
    return "redirect:/bookPage";
  }
  @RequestMapping(value = "/addBook", method = RequestMethod.POST)
  public String addBook2(
      @RequestParam("bookname") String bookname,
      @RequestParam("author") String author,
      @RequestParam("publish") String publish,
      @RequestParam("isbn") String isbn,
      @RequestParam("publishdate") String publishdate,
      @RequestParam("repertory") String repertory,
      @RequestParam("price") Double price,
      @RequestParam("stock") Integer stock,
      @RequestParam("bookOneclassid") Integer bookOneclassid,
      @RequestParam(value = "bookTwoclassid", required = false) Integer bookTwoclassid,
      @RequestParam(value = "bookThreeclassid", required = false) Integer bookThreeclassid,
      @RequestParam(value = "isrecommend", required = false) String isrecommend,
      @RequestParam("intro") String intro,
      @RequestParam("picture") MultipartFile file,
      Model model)
      throws JsonGenerationException, JsonMappingException, IOException {
    // 上传图片
    logger.info("POST---添加图书---");

    String fileName = file.getOriginalFilename();
    logger.info("原文件名" + fileName);
    String path = "O:\\picc\\";
    String newFileName = "";
    if (file != null && fileName != null && fileName.length() > 0) {
      newFileName = UUID.randomUUID() + fileName.substring(fileName.lastIndexOf("."));
      File newFile = new File(path + newFileName);
      file.transferTo(newFile);

      logger.info("上传成功");
    }

    Book book = new Book();
    book.setAuthor(author);
    Integer bookclassid = null;
    System.out.println("bookThreeclassid===>" + bookThreeclassid);
    System.out.println("bookTwoclassid===>" + bookTwoclassid);
    System.out.println("bookOneclassid===>" + bookOneclassid);
    if (bookThreeclassid > new Integer(-1)) {
      bookclassid = bookThreeclassid;
    } else if (bookTwoclassid > new Integer(-1)) {
      bookclassid = bookTwoclassid;

    } else {
      bookclassid = bookOneclassid;
    }
    System.out.println("图书价格:" + price);

    Double tsprice = Double.parseDouble(String.format("%.2f", price));
    System.out.println(tsprice);

    System.out.println(bookclassid);
    book.setBookclassid(bookclassid);
    book.setBookname(bookname);
    book.setIntro(intro);
    book.setIsbn(isbn);

    if (isrecommend == null) {
      isrecommend = "0";
    }
    logger.info(isrecommend);
    book.setPublishdate(publishdate);
    book.setIsrecommend(isrecommend);
    book.setPicture(newFileName);
    book.setPrice(tsprice);
    book.setPublish(publish);
    book.setRepertory(repertory);
    book.setSales(0);
    book.setStock(stock);
    ObjectMapper mapper = new ObjectMapper();
    logger.info(mapper.writeValueAsString(book));
    System.out.println(book);
    bookService.addBook(book);
    return "redirect:/bookPage";
  }