From 569e6618a8cf09664a32eb67efcef17271a2a130 Mon Sep 17 00:00:00 2001 From: Eg <1711788888@qq.com> Date: Thu, 2 Jun 2022 16:22:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=96=B0=E5=A2=9E=E8=B7=AF=E7=94=B1||?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/response.go | 10 ++++++++++ go.mod | 1 - route/router.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/response.go b/core/response.go index 086016e..f4cc8e1 100644 --- a/core/response.go +++ b/core/response.go @@ -3,6 +3,7 @@ package core import ( "github.com/gin-gonic/gin" "net/http" + "online_code/utils" ) // 返回数据包装 @@ -59,6 +60,15 @@ func (r rs) OkDetailed(data interface{}, message string) { r.Result(SUCCESS, data, message) } +// OkDataPage 返回分页数据 +func (r rs) OkDataPage(count int64, page PageData) { + // 计算总页码 + totalPage := utils.GenTotalPage(count, page.Size) + page.TotalPage = totalPage + // 返回结果 + r.Result(SUCCESS, page, "操作成功") +} + // Fail 返回默认失败 func (r rs) Fail() { r.Result(ERROR, nil, "操作失败") diff --git a/go.mod b/go.mod index 206d81b..21ff359 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/fsnotify/fsnotify v1.5.1 github.com/gin-gonic/gin v1.7.7 github.com/go-redis/redis/v8 v8.11.5 - github.com/google/uuid v1.1.2 github.com/spf13/viper v1.10.1 golang.org/x/crypto v0.0.0-20220214200702-86341886e292 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c diff --git a/route/router.go b/route/router.go index 9cbf193..d98aa36 100644 --- a/route/router.go +++ b/route/router.go @@ -4,4 +4,5 @@ import "github.com/gin-gonic/gin" func InitRoute(g *gin.RouterGroup) { problem(g.Group("/problem")) + user(g.Group("/user")) }