|
@@ -1,12 +1,10 @@
|
|
|
package com.sf.controller;
|
|
|
|
|
|
-import com.sf.dto.resp.BookCategoryRespDto;
|
|
|
+import com.sf.dto.resp.*;
|
|
|
import com.sf.dto.RestResp;
|
|
|
import com.sf.dto.req.BookSearchReqDto;
|
|
|
-import com.sf.dto.resp.BookInfoRespDto;
|
|
|
-import com.sf.dto.resp.BookRankRespDto;
|
|
|
-import com.sf.dto.resp.PageRespDto;
|
|
|
import com.sf.entity.BookInfo;
|
|
|
+import com.sf.service.IBookChapterService;
|
|
|
import com.sf.service.IBookInfoService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
@@ -25,7 +23,7 @@ import java.util.List;
|
|
|
* @author baomidou
|
|
|
* @since 2024-05-25
|
|
|
*/
|
|
|
-@Tag(name = "BookInfoController",description = "小说信息模块")
|
|
|
+@Tag(name = "BookInfoController", description = "小说信息模块")
|
|
|
@RestController
|
|
|
//@RequestMapping("/api/front/book")
|
|
|
public class BookInfoController {
|
|
@@ -33,18 +31,22 @@ public class BookInfoController {
|
|
|
@Autowired
|
|
|
private IBookInfoService bookInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBookChapterService bookChapterService;
|
|
|
+
|
|
|
// http://localhost:8888/api/front/book/list
|
|
|
- @GetMapping("/api/front/book/list")
|
|
|
- public List<BookInfo> list(){
|
|
|
- // 不需要编写sql语句 直接进行增删改查操作
|
|
|
- return bookInfoService.list();
|
|
|
- }
|
|
|
+ // 测试用
|
|
|
+// @GetMapping("/api/front/book/list")
|
|
|
+// public List<BookInfo> list() {
|
|
|
+// // 不需要编写sql语句 直接进行增删改查操作
|
|
|
+// return bookInfoService.list();
|
|
|
+// }
|
|
|
|
|
|
// http://127.0.0.1:8888/api/front/book/{id}
|
|
|
- @Operation(summary = "小说信息查询接口")
|
|
|
+ @Operation(summary = "书籍信息查询接口")
|
|
|
@GetMapping("/api/front/book/{id}")
|
|
|
public RestResp<BookInfoRespDto> getBookInfoById(
|
|
|
- @Parameter(description = "小说id") @PathVariable("id") Long id){
|
|
|
+ @Parameter(description = "小说id") @PathVariable("id") Long id) {
|
|
|
// getById是mybatis plus提供的方法
|
|
|
// 从对应表中 where id = '' 中的数据取出
|
|
|
// mapper中 对应的方法叫 selectById
|
|
@@ -67,11 +69,12 @@ public class BookInfoController {
|
|
|
// http://127.0.0.1:8888/api/front/search/books?keyword=&pageSize=10&pageNum=2
|
|
|
@Operation(summary = "查询书籍列表接口")
|
|
|
@GetMapping("/api/front/search/books")
|
|
|
- public RestResp<PageRespDto<BookInfoRespDto>> searchBooks(BookSearchReqDto bookSearchReqDto){
|
|
|
+ public RestResp<PageRespDto<BookInfoRespDto>> searchBooks(BookSearchReqDto bookSearchReqDto) {
|
|
|
PageRespDto<BookInfoRespDto> pageRespDto = bookInfoService.searchBooks(bookSearchReqDto);
|
|
|
return RestResp.ok(pageRespDto);
|
|
|
}
|
|
|
|
|
|
+ @Operation(summary = "查询书籍分类接口")
|
|
|
@GetMapping("/api/front/book/category/list")
|
|
|
public RestResp<List<BookCategoryRespDto>> listCategory(
|
|
|
@Parameter(description = "作品方向", required = false) Integer workDirection) {
|
|
@@ -79,22 +82,35 @@ public class BookInfoController {
|
|
|
return RestResp.ok(bookCategoryRespDtos);
|
|
|
}
|
|
|
|
|
|
+ @Operation(summary = "点击量排行榜接口")
|
|
|
@GetMapping("/api/front/book/visit_rank")
|
|
|
public RestResp<List<BookRankRespDto>> listVisitRankBooks() {
|
|
|
List<BookRankRespDto> bookRankRespDtos = bookInfoService.listVisitRankBooks();
|
|
|
return RestResp.ok(bookRankRespDtos);
|
|
|
}
|
|
|
|
|
|
+ @Operation(summary = "新书排行榜接口")
|
|
|
@GetMapping("/api/front/book/newest_rank")
|
|
|
public RestResp<List<BookRankRespDto>> listNewestRankBooks() {
|
|
|
List<BookRankRespDto> bookRankRespDtos = bookInfoService.listNewestRankBooks();
|
|
|
return RestResp.ok(bookRankRespDtos);
|
|
|
}
|
|
|
|
|
|
+ @Operation(summary = "更新排行榜接口")
|
|
|
@GetMapping("/api/front/book/update_rank")
|
|
|
public RestResp<List<BookRankRespDto>> listUpdateRankBooks() {
|
|
|
List<BookRankRespDto> bookRankRespDtos = bookInfoService.listUpdateRankBooks();
|
|
|
return RestResp.ok(bookRankRespDtos);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 最新章节请求
|
|
|
+ // http://127.0.0.1:8888/api/front/book/last_chapter/about?bookId=1431630596354977794
|
|
|
+ @Operation(summary = "最新章节接口")
|
|
|
+ @GetMapping("/api/front/book/last_chapter/about")
|
|
|
+ public RestResp<BookChapterAboutRespDto> lastChapterAbout(@RequestParam("bookId") Long bookId) {
|
|
|
+ BookChapterAboutRespDto chapterAboutRespDto = bookChapterService.lastChapterAbout(bookId);
|
|
|
+ return RestResp.ok(chapterAboutRespDto);
|
|
|
+ }
|
|
|
+
|
|
|
}
|