From 991165125f3ed1917a39c845b198f66c7d3f7b88 Mon Sep 17 00:00:00 2001 From: Eg <1711788888@qq.com> Date: Thu, 2 Jun 2022 16:21:08 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/problem.go | 6 ++---- repository/problem.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/api/problem.go b/api/problem.go index faa977a..a973aba 100644 --- a/api/problem.go +++ b/api/problem.go @@ -5,7 +5,6 @@ import ( "online_code/core" "online_code/models/param" "online_code/repository" - "online_code/utils" ) type problemApi struct{} @@ -26,8 +25,7 @@ func (problemApi) GetProbleList(ctx *gin.Context) { core.R(ctx).FailWithMessage("获取题目列表失败: " + err.Error()) return } - // 计算总页码 - totalPage := utils.GenTotalPage(count, p.Size) + // 返回结果 - core.R(ctx).OkWithData(core.PageData{Current: p.Current, Size: p.Size, Total: count, TotalPage: totalPage, Records: records}) + core.R(ctx).OkDataPage(count, core.PageData{Current: p.Current, Size: p.Size, Total: count, Records: records}) } diff --git a/repository/problem.go b/repository/problem.go index e02fa0c..e63ea29 100644 --- a/repository/problem.go +++ b/repository/problem.go @@ -13,7 +13,7 @@ func ProblemService() *problemService { } // GetList 获取题目列表 -func (problemService) GetList(p param.GetProblemList) (records entity.ProblemBasic, count int64, err error) { +func (problemService) GetList(p param.GetProblemList) (records []entity.ProblemBasic, count int64, err error) { sel := client.MySQL.Scopes(page(p.Current, p.Size)).Preload("ProblemCategories").Preload("ProblemCategories.CategoryBasic") if p.Keyword != "" {