修改分页逻辑
This commit is contained in:
parent
9a017e7606
commit
73f0b7639a
@ -10,7 +10,7 @@ export class ArticleController extends BaseController {
|
|||||||
async query(req: any) {
|
async query(req: any) {
|
||||||
let { start, limit, page} = req.params
|
let { start, limit, page} = req.params
|
||||||
limit = +limit || 10
|
limit = +limit || 10
|
||||||
start = +start || (+page - 1) * start|| 0
|
start = +start || (+page - 1) * limit|| 0
|
||||||
let { opt, sort } = Article.parseQueryParam(req.params)
|
let { opt, sort } = Article.parseQueryParam(req.params)
|
||||||
let articles = await Article.find(opt)
|
let articles = await Article.find(opt)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
|
@ -9,7 +9,7 @@ class CouponController extends BaseController{
|
|||||||
async list(req, res) {
|
async list(req, res) {
|
||||||
let { start, limit, page } = req.params
|
let { start, limit, page } = req.params
|
||||||
limit = +limit || 10
|
limit = +limit || 10
|
||||||
start = +start || (+page - 1) * start|| 0
|
start = +start || (+page - 1) * limit|| 0
|
||||||
let { opt, sort } = Coupon.parseQueryParam(req.params)
|
let { opt, sort } = Coupon.parseQueryParam(req.params)
|
||||||
let articles = await Coupon.find(opt)
|
let articles = await Coupon.find(opt)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
|
@ -9,7 +9,7 @@ class GameController extends BaseController{
|
|||||||
async list(req, res) {
|
async list(req, res) {
|
||||||
let { start, limit, page } = req.params
|
let { start, limit, page } = req.params
|
||||||
limit = +limit || 10
|
limit = +limit || 10
|
||||||
start = +start || (+page - 1) * start|| 0
|
start = +start || (+page - 1) * limit|| 0
|
||||||
let { opt, sort } = Game.parseQueryParam(req.params)
|
let { opt, sort } = Game.parseQueryParam(req.params)
|
||||||
let articles = await Game.find(opt)
|
let articles = await Game.find(opt)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
|
@ -11,7 +11,7 @@ class PuzzleController extends BaseController{
|
|||||||
async list(req, res) {
|
async list(req, res) {
|
||||||
let { start, limit, page } = req.params
|
let { start, limit, page } = req.params
|
||||||
limit = +limit || 10
|
limit = +limit || 10
|
||||||
start = +start || (+page - 1) * start|| 0
|
start = +start || (+page - 1) * limit|| 0
|
||||||
let { opt, sort } = Puzzle.parseQueryParam(req.params)
|
let { opt, sort } = Puzzle.parseQueryParam(req.params)
|
||||||
let articles = await Puzzle.find(opt)
|
let articles = await Puzzle.find(opt)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
|
@ -11,7 +11,7 @@ class ShopController extends BaseController {
|
|||||||
async shopList(req, res) {
|
async shopList(req, res) {
|
||||||
let { start, limit, page } = req.params
|
let { start, limit, page } = req.params
|
||||||
limit = +limit || 10
|
limit = +limit || 10
|
||||||
start = +start || (+page - 1) * start|| 0
|
start = +start || (+page - 1) * limit|| 0
|
||||||
let { opt, sort } = Shop.parseQueryParam(req.params)
|
let { opt, sort } = Shop.parseQueryParam(req.params)
|
||||||
let articles = await Shop.find(opt)
|
let articles = await Shop.find(opt)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user