|
@@ -7,11 +7,13 @@ import com.sf.dto.req.BookSearchReqDto;
|
|
import com.sf.entity.BookInfo;
|
|
import com.sf.entity.BookInfo;
|
|
import com.sf.service.IBookChapterService;
|
|
import com.sf.service.IBookChapterService;
|
|
import com.sf.service.IBookInfoService;
|
|
import com.sf.service.IBookInfoService;
|
|
|
|
+import com.sf.service.IBookRankService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
@@ -34,6 +36,10 @@ public class BookInfoController {
|
|
@Autowired
|
|
@Autowired
|
|
private IBookInfoService bookInfoService;
|
|
private IBookInfoService bookInfoService;
|
|
|
|
|
|
|
|
+ @Qualifier("bookRankServiceByRedis")
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBookRankService bookRankService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private IBookChapterService bookChapterService;
|
|
private IBookChapterService bookChapterService;
|
|
|
|
|
|
@@ -85,27 +91,6 @@ public class BookInfoController {
|
|
return RestResp.ok(bookCategoryRespDtos);
|
|
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
|
|
// http://127.0.0.1:8888/api/front/book/last_chapter/about?bookId=1431630596354977794
|
|
@@ -120,7 +105,9 @@ public class BookInfoController {
|
|
@PostMapping("/api/front/book/visit")
|
|
@PostMapping("/api/front/book/visit")
|
|
public RestResp<Void> addVisitCount(@Parameter(description = "小说ID")
|
|
public RestResp<Void> addVisitCount(@Parameter(description = "小说ID")
|
|
@RequestBody BookVisitReqDto reqDto) {
|
|
@RequestBody BookVisitReqDto reqDto) {
|
|
- bookInfoService.addVisitCount(Long.parseLong(reqDto.getBookId()));
|
|
|
|
|
|
+ long bookId = Long.parseLong(reqDto.getBookId());
|
|
|
|
+ bookRankService.updateVisitRank(bookId);
|
|
|
|
+ bookInfoService.addVisitCount(bookId);
|
|
return RestResp.ok(null);
|
|
return RestResp.ok(null);
|
|
}
|
|
}
|
|
|
|
|