BookController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package com.hssx.bms.controller;
  2. import com.hssx.bms.entity.Book;
  3. import com.hssx.bms.entity.BookCategory;
  4. import com.hssx.bms.entity.BookPage;
  5. import com.hssx.bms.service.BookCategoryService;
  6. import com.hssx.bms.service.BookPageService;
  7. import com.hssx.bms.service.BookService;
  8. import com.hssx.bms.until.HttpRespMsg;
  9. import com.hssx.bms.until.PageUtil;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import java.util.List;
  18. /**
  19. * @author 吴涛涛
  20. * @since 2019-10-16
  21. */
  22. @Controller
  23. @RequestMapping("/book")
  24. public class BookController {
  25. @Autowired
  26. private BookService bookService;
  27. @Autowired
  28. private BookPageService bookPageService;
  29. @Autowired
  30. private BookCategoryService bookCategoryService;
  31. /**
  32. * 图书信息的录入
  33. * 参数:name 名称,author 作者,descrip 描述
  34. * file 封面文件(可不传)
  35. * 修改时需要:id 图书id
  36. * @return
  37. */
  38. @ApiOperation(value = "图书信息的录入", notes = "图书信息的录入")
  39. @RequestMapping("/addOrUpdateBook")
  40. @ResponseBody
  41. public HttpRespMsg addOrUpdateBook(Book book, @RequestParam(required = false) MultipartFile file){
  42. HttpRespMsg msg = bookService.addOrUpdateBook(book,file);
  43. return msg;
  44. }
  45. /**
  46. * 图书信息的列表
  47. * 参数:
  48. * @return
  49. */
  50. @ApiOperation(value = "图书信息的列表", notes = "图书信息的列表方法")
  51. @RequestMapping("/list")
  52. @ResponseBody
  53. public HttpRespMsg list(PageUtil page){
  54. HttpRespMsg msg = bookService.getList(page);
  55. return msg;
  56. }
  57. /**
  58. * 图书信息的录入
  59. * 参数:bookId 图书对应的id
  60. * file 上传的图书图片文件zip(内部文件命名按照对应页码命名如1.jpg:第一页)
  61. * @return
  62. */
  63. @ApiOperation(value = "图书图片的上传", notes = "图书图片的上传方法")
  64. @RequestMapping("/addBookPage")
  65. @ResponseBody
  66. public HttpRespMsg addBookPage(BookPage bookPage, @RequestParam(required = false) MultipartFile zipFile){
  67. HttpRespMsg msg = bookPageService.addBookPage(bookPage,zipFile);
  68. return msg;
  69. }
  70. /**
  71. * 图书图片删除
  72. * 参数:id 图书图片对应的id
  73. * @return
  74. */
  75. @ApiOperation(value = "图书图片删除", notes = "图书图片删除方法")
  76. @RequestMapping("/deleteBookPage")
  77. @ResponseBody
  78. public HttpRespMsg deleteBookPage(BookPage bookPage){
  79. HttpRespMsg msg = new HttpRespMsg();
  80. msg.data = bookPageService.removeById(bookPage.getId());
  81. return msg;
  82. }
  83. /**
  84. * 单个图书图片列表(图片总张数)
  85. * 参数:bookId 图书的id
  86. * @return
  87. */
  88. @ApiOperation(value = "单个图书图片列表(图片总张数)", notes = "单个图书图片列表(图片总张数)方法")
  89. @RequestMapping("/bookPageList")
  90. @ResponseBody
  91. public HttpRespMsg bookPageList(BookPage bookPage){
  92. HttpRespMsg msg = bookPageService.getBookPageList(bookPage);
  93. return msg;
  94. }
  95. /**
  96. * 图书目录的录入/修改
  97. * 参数:bookId 图书id rank 章节(对应数字0-序 1-第一章 2-第二章...)
  98. * name 目录名称 pageNum 起始页码
  99. * 修改时:需要传 id 目录的id
  100. * @return
  101. */
  102. @ApiOperation(value = "图书目录的录入和修改", notes = "图书目录的录入和修改方法")
  103. @RequestMapping("/addOrUpdateRank")
  104. @ResponseBody
  105. public HttpRespMsg addOrUpdateRank(BookCategory BookCategory){
  106. HttpRespMsg msg = bookCategoryService.addOrUpdateRank(BookCategory);
  107. return msg;
  108. }
  109. /**
  110. * 图书目录的删除
  111. * 修改时:需要传 id 目录的id
  112. * @return
  113. */
  114. @ApiOperation(value = "图书目录的删除", notes = "图书目录的删除方法")
  115. @RequestMapping("/delRank")
  116. @ResponseBody
  117. public HttpRespMsg delRank(BookCategory BookCategory){
  118. HttpRespMsg msg = new HttpRespMsg();
  119. bookCategoryService.removeById(BookCategory.getId());
  120. return msg;
  121. }
  122. /**
  123. * 图书详情
  124. * 参数 id 图书id
  125. * @param book
  126. * @return
  127. */
  128. @ApiOperation(value = "图书详情", notes = "图书详情")
  129. @RequestMapping("/detail")
  130. @ResponseBody
  131. public HttpRespMsg detail(Book book){
  132. HttpRespMsg msg = new HttpRespMsg();
  133. msg = bookService.getBookDetailById(book.getId());
  134. return msg;
  135. }
  136. /**
  137. * 图书的删除
  138. * 参数 id 图书id
  139. * @param book
  140. * @return
  141. */
  142. @ApiOperation(value = "图书的删除 ", notes = "图书删除方法")
  143. @RequestMapping("/del")
  144. @ResponseBody
  145. public HttpRespMsg del(Book book){
  146. HttpRespMsg msg = new HttpRespMsg();
  147. msg = bookService.del(book.getId());
  148. return msg;
  149. }
  150. }