|
@@ -10,6 +10,7 @@ import com.book.server.model.VO.BookRes;
|
|
|
import com.book.server.model.VO.Chapter;
|
|
|
import com.book.server.model.VO.QueryVO;
|
|
|
import com.book.server.service.BookService;
|
|
|
+import com.mysql.cj.QueryBindings;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
@@ -17,6 +18,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -53,6 +55,21 @@ public class BookController extends BaseController {
|
|
|
return Result.success(bookService.recommendByRead(queryVO));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 热门推荐4个
|
|
|
+ * @param queryVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/topRecommend")
|
|
|
+ public Result<List<Book>> topRecommend(@RequestBody QueryVO queryVO) {
|
|
|
+ queryVO.setPage(0);
|
|
|
+ queryVO.setSize(10);
|
|
|
+ queryVO.setPageId(queryVO.getSex()); // 为了复用recommendByRead的代码
|
|
|
+ List<Book> books = bookService.recommendByRead(queryVO);
|
|
|
+ Collections.shuffle(books);
|
|
|
+ return Result.success(books.subList(0, 4));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 书城block
|
|
|
*
|