mirror of
https://github.com/201206030/novel-plus.git
synced 2025-09-14 05:02:43 +00:00
perf: 优化排序参数校验
This commit is contained in:
@@ -15,6 +15,7 @@ import io.github.xxyopen.model.resp.RestResult;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -82,7 +83,7 @@ public class BookController extends BaseController {
|
||||
* 分页搜索
|
||||
*/
|
||||
@GetMapping("searchByPage")
|
||||
public RestResult<?> searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
public RestResult<?> searchByPage(@Validated BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "20") int pageSize) {
|
||||
return RestResult.ok(bookService.searchByPage(bookSP, page, pageSize));
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
public interface FrontBookMapper extends BookMapper {
|
||||
|
||||
|
||||
List<BookVO> searchByPage(@ValidateSortOrder BookSpVO params);
|
||||
List<BookVO> searchByPage(BookSpVO params);
|
||||
|
||||
void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount);
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.java2nb.novel.vo;
|
||||
|
||||
import com.java2nb.novel.core.vo.SortOrderVO;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -10,7 +11,7 @@ import java.util.Date;
|
||||
* @author 11797
|
||||
*/
|
||||
@Data
|
||||
public class BookSpVO extends SortOrderVO {
|
||||
public class BookSpVO {
|
||||
|
||||
private String keyword;
|
||||
|
||||
@@ -30,5 +31,8 @@ public class BookSpVO extends SortOrderVO {
|
||||
|
||||
private Long updatePeriod;
|
||||
|
||||
@Pattern(regexp = "^(last_index_update_time|word_count|visit_count)$")
|
||||
private String sort;
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user