mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-06 01:06:39 +00:00
部分代码重构
This commit is contained in:
@ -6,7 +6,11 @@ import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.BookCategory;
|
||||
import com.java2nb.novel.entity.BookComment;
|
||||
import com.java2nb.novel.entity.BookIndex;
|
||||
import com.java2nb.novel.vo.BookCommentVO;
|
||||
import com.java2nb.novel.vo.BookSettingVO;
|
||||
import com.java2nb.novel.vo.BookSpVO;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.vo.BookVO;
|
||||
@ -18,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -41,7 +46,7 @@ public class BookController extends BaseController{
|
||||
* 查询首页小说设置列表数据
|
||||
* */
|
||||
@GetMapping("listBookSetting")
|
||||
public ResultBean listBookSetting(){
|
||||
public ResultBean<Map<Byte, List<BookSettingVO>>> listBookSetting(){
|
||||
return ResultBean.ok(bookService.listBookSettingVO());
|
||||
}
|
||||
|
||||
@ -49,7 +54,7 @@ public class BookController extends BaseController{
|
||||
* 查询首页点击榜单数据
|
||||
* */
|
||||
@GetMapping("listClickRank")
|
||||
public ResultBean listClickRank(){
|
||||
public ResultBean<List<Book>> listClickRank(){
|
||||
return ResultBean.ok(bookService.listClickRank());
|
||||
}
|
||||
|
||||
@ -57,7 +62,7 @@ public class BookController extends BaseController{
|
||||
* 查询首页新书榜单数据
|
||||
* */
|
||||
@GetMapping("listNewRank")
|
||||
public ResultBean listNewRank(){
|
||||
public ResultBean<List<Book>> listNewRank(){
|
||||
return ResultBean.ok(bookService.listNewRank());
|
||||
}
|
||||
|
||||
@ -65,7 +70,7 @@ public class BookController extends BaseController{
|
||||
* 查询首页更新榜单数据
|
||||
* */
|
||||
@GetMapping("listUpdateRank")
|
||||
public ResultBean listUpdateRank(){
|
||||
public ResultBean<List<BookVO>> listUpdateRank(){
|
||||
return ResultBean.ok(bookService.listUpdateRank());
|
||||
}
|
||||
|
||||
@ -73,7 +78,7 @@ public class BookController extends BaseController{
|
||||
* 查询小说分类列表
|
||||
* */
|
||||
@GetMapping("listBookCategory")
|
||||
public ResultBean listBookCategory(){
|
||||
public ResultBean<List<BookCategory>> listBookCategory(){
|
||||
return ResultBean.ok(bookService.listBookCategory());
|
||||
}
|
||||
|
||||
@ -81,7 +86,7 @@ public class BookController extends BaseController{
|
||||
* 分页搜索
|
||||
* */
|
||||
@GetMapping("searchByPage")
|
||||
public ResultBean searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
||||
public ResultBean<?> searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
||||
return ResultBean.ok(bookService.searchByPage(bookSP,page,pageSize));
|
||||
}
|
||||
|
||||
@ -89,7 +94,7 @@ public class BookController extends BaseController{
|
||||
* 查询小说详情信息
|
||||
* */
|
||||
@GetMapping("queryBookDetail/{id}")
|
||||
public ResultBean queryBookDetail(@PathVariable("id") Long id){
|
||||
public ResultBean<Book> queryBookDetail(@PathVariable("id") Long id){
|
||||
return ResultBean.ok(bookService.queryBookDetail(id));
|
||||
}
|
||||
|
||||
@ -98,7 +103,7 @@ public class BookController extends BaseController{
|
||||
* 查询小说排行信息
|
||||
* */
|
||||
@GetMapping("listRank")
|
||||
public ResultBean listRank(@RequestParam(value = "type",defaultValue = "0") Byte type,@RequestParam(value = "limit",defaultValue = "30") Integer limit){
|
||||
public ResultBean<List<Book>> listRank(@RequestParam(value = "type",defaultValue = "0") Byte type,@RequestParam(value = "limit",defaultValue = "30") Integer limit){
|
||||
return ResultBean.ok(bookService.listRank(type,limit));
|
||||
}
|
||||
|
||||
@ -106,7 +111,7 @@ public class BookController extends BaseController{
|
||||
* 增加点击次数
|
||||
* */
|
||||
@PostMapping("addVisitCount")
|
||||
public ResultBean addVisitCount(Long bookId){
|
||||
public ResultBean<Void> addVisitCount(Long bookId){
|
||||
if(enableMq == 1) {
|
||||
rabbitTemplate.convertAndSend("ADD-BOOK-VISIT-EXCHANGE", null, bookId);
|
||||
}else {
|
||||
@ -119,7 +124,7 @@ public class BookController extends BaseController{
|
||||
* 查询章节相关信息
|
||||
* */
|
||||
@GetMapping("queryBookIndexAbout")
|
||||
public ResultBean queryBookIndexAbout(Long bookId,Long lastBookIndexId) {
|
||||
public ResultBean<Map<String,Object>> queryBookIndexAbout(Long bookId,Long lastBookIndexId) {
|
||||
Map<String,Object> data = new HashMap<>(2);
|
||||
data.put("bookIndexCount",bookService.queryIndexCount(bookId));
|
||||
String lastBookContent = bookService.queryBookContent(lastBookIndexId).getContent();
|
||||
@ -134,7 +139,7 @@ public class BookController extends BaseController{
|
||||
* 根据分类id查询同类推荐书籍
|
||||
* */
|
||||
@GetMapping("listRecBookByCatId")
|
||||
public ResultBean listRecBookByCatId(Integer catId) {
|
||||
public ResultBean<List<Book>> listRecBookByCatId(Integer catId) {
|
||||
return ResultBean.ok(bookService.listRecBookByCatId(catId));
|
||||
}
|
||||
|
||||
@ -143,7 +148,7 @@ public class BookController extends BaseController{
|
||||
*分页查询书籍评论列表
|
||||
* */
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean listCommentByPage(@RequestParam("bookId") Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
public ResultBean<PageBean<BookCommentVO>> listCommentByPage(@RequestParam("bookId") Long bookId, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
return ResultBean.ok(bookService.listCommentByPage(null,bookId,page,pageSize));
|
||||
}
|
||||
|
||||
@ -151,7 +156,7 @@ public class BookController extends BaseController{
|
||||
* 新增评价
|
||||
* */
|
||||
@PostMapping("addBookComment")
|
||||
public ResultBean addBookComment(BookComment comment, HttpServletRequest request) {
|
||||
public ResultBean<?> addBookComment(BookComment comment, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
@ -164,7 +169,7 @@ public class BookController extends BaseController{
|
||||
* 根据小说ID查询小说前十条最新更新目录集合
|
||||
* */
|
||||
@GetMapping("queryNewIndexList")
|
||||
public ResultBean queryNewIndexList(Long bookId){
|
||||
public ResultBean<List<BookIndex>> queryNewIndexList(Long bookId){
|
||||
return ResultBean.ok(bookService.queryIndexList(bookId,"index_num desc",1,10));
|
||||
}
|
||||
|
||||
@ -172,7 +177,7 @@ public class BookController extends BaseController{
|
||||
* 目录页
|
||||
* */
|
||||
@GetMapping("/queryIndexList")
|
||||
public ResultBean indexList(Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,@RequestParam(value = "orderBy",defaultValue = "index_num desc") String orderBy) {
|
||||
public ResultBean<PageBean<BookIndex>> indexList(Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,@RequestParam(value = "orderBy",defaultValue = "index_num desc") String orderBy) {
|
||||
return ResultBean.ok(new PageBean<>(bookService.queryIndexList(bookId,orderBy,page,pageSize)));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user