refactor: 重构小说搜索接口

This commit is contained in:
xiongxiaoyang 2022-05-27 16:04:26 +08:00
parent 20a2d64cc1
commit e537240c73
3 changed files with 46 additions and 14 deletions

View File

@ -1,12 +1,9 @@
package io.github.xxyopen.novel.controller.front; package io.github.xxyopen.novel.controller.front;
import io.github.xxyopen.novel.core.common.resp.PageRespDto;
import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
import io.github.xxyopen.novel.core.common.resp.RestResp; import io.github.xxyopen.novel.core.common.resp.RestResp;
import io.github.xxyopen.novel.dto.req.BookSearchReqDto; import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
import io.github.xxyopen.novel.dto.resp.*; import io.github.xxyopen.novel.dto.resp.*;
import io.github.xxyopen.novel.service.BookService; import io.github.xxyopen.novel.service.BookService;
import io.github.xxyopen.novel.service.SearchService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -26,8 +23,6 @@ public class BookController {
private final BookService bookService; private final BookService bookService;
private final SearchService searchService;
/** /**
* 小说分类列表查询接口 * 小说分类列表查询接口
*/ */
@ -36,14 +31,6 @@ public class BookController {
return bookService.listCategory(workDirection); return bookService.listCategory(workDirection);
} }
/**
* 小说搜索接口
*/
@GetMapping("search_list")
public RestResp<PageRespDto<BookInfoRespDto>> searchBooks(BookSearchReqDto condition) {
return searchService.searchBooks(condition);
}
/** /**
* 小说信息查询接口 * 小说信息查询接口
*/ */

View File

@ -0,0 +1,35 @@
package io.github.xxyopen.novel.controller.front;
import io.github.xxyopen.novel.core.common.resp.PageRespDto;
import io.github.xxyopen.novel.core.common.resp.RestResp;
import io.github.xxyopen.novel.core.constant.ApiRouterConsts;
import io.github.xxyopen.novel.dto.req.BookSearchReqDto;
import io.github.xxyopen.novel.dto.resp.BookInfoRespDto;
import io.github.xxyopen.novel.service.SearchService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 前台门户-搜索模块 API 控制器
*
* @author xiongxiaoyang
* @date 2022/5/27
*/
@RestController
@RequestMapping(ApiRouterConsts.API_FRONT_SEARCH_URL_PREFIX)
@RequiredArgsConstructor
public class SearchController {
private final SearchService searchService;
/**
* 小说搜索接口
*/
@GetMapping("books")
public RestResp<PageRespDto<BookInfoRespDto>> searchBooks(BookSearchReqDto condition) {
return searchService.searchBooks(condition);
}
}

View File

@ -57,6 +57,11 @@ public class ApiRouterConsts {
* */ * */
public static final String RESOURCE_URL_PREFIX = "/resource"; public static final String RESOURCE_URL_PREFIX = "/resource";
/**
* 搜索模块请求路径前缀
* */
public static final String SEARCH_URL_PREFIX = "/search";
/** /**
* 前台门户首页API请求路径前缀 * 前台门户首页API请求路径前缀
*/ */
@ -82,4 +87,9 @@ public class ApiRouterConsts {
*/ */
public static final String API_FRONT_RESOURCE_URL_PREFIX = API_FRONT_URL_PREFIX + RESOURCE_URL_PREFIX; public static final String API_FRONT_RESOURCE_URL_PREFIX = API_FRONT_URL_PREFIX + RESOURCE_URL_PREFIX;
/**
* 前台门户搜索相关API请求路径前缀
* */
public static final String API_FRONT_SEARCH_URL_PREFIX = API_FRONT_URL_PREFIX + SEARCH_URL_PREFIX;
} }