From 3532dc294e677265efcf4ce61c79ff5c0277ff36 Mon Sep 17 00:00:00 2001 From: wangjian Date: Fri, 6 Jan 2023 16:10:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/middleware/jwt.go | 2 +- internal/proto/response.go | 18 +++++++++--------- internal/service/index.go | 31 ++++++++++++++++++++----------- model/index.go | 2 ++ 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/internal/middleware/jwt.go b/internal/middleware/jwt.go index 0ec1538..084c59d 100644 --- a/internal/middleware/jwt.go +++ b/internal/middleware/jwt.go @@ -68,7 +68,7 @@ func JwtAuthMiddleware(logger *zap.Logger) gin.HandlerFunc { usClaims *Claims user *model.SystemUser ) - token := c.GetHeader("token") + token := c.GetHeader("Authorization") // 这里可以过滤不需要进行验证的接口 if path == "/user/login" || path == "/health" { goto Return diff --git a/internal/proto/response.go b/internal/proto/response.go index 0fea006..3daf080 100644 --- a/internal/proto/response.go +++ b/internal/proto/response.go @@ -2,15 +2,15 @@ package proto // BaseResponse 基础返回结构 type BaseResponse struct { - Code int `json:"code"` - Message string `json:"message"` - Data interface{} `json:"result,omitempty"` - Status string `json:"type,omitempty"` - Err error `json:"error,omitempty"` // 错误堆栈 - Page int64 `json:"page,omitempty"` //当前页码 - PageSize int64 `json:"pageSize,omitempty"` // 单页显示记录数--前端参数2 - PageCount int64 `json:"totalPage,omitempty"` // 总页数 - TotalSize int64 `json:"totalRow,omitempty"` // 总记录数 + Code int `json:"code"` + Message string `json:"message"` + Data interface{} `json:"result,omitempty"` + Status string `json:"type,omitempty"` + Err error `json:"error,omitempty"` // 错误堆栈 + //Page int64 `json:"page,omitempty"` //当前页码 + //PageSize int64 `json:"pageSize,omitempty"` // 单页显示记录数--前端参数2 + //PageCount int64 `json:"totalPage,omitempty"` // 总页数 + //TotalSize int64 `json:"total,omitempty"` // 总记录数 } type UserLoginResponse struct { diff --git a/internal/service/index.go b/internal/service/index.go index 0edad5d..c5563e5 100644 --- a/internal/service/index.go +++ b/internal/service/index.go @@ -14,19 +14,28 @@ import ( "xorm.io/xorm" ) +type PagingStruct struct { + List interface{} `json:"list"` + Total int64 `json:"total"` +} + // FillPaging 填充分页数据 func FillPaging(count int64, pageNum int64, pageSize int64, list interface{}, data *proto.BaseResponse) *proto.BaseResponse { - var tp int64 - if count%pageSize > 0 { - tp = count/pageSize + 1 - } else { - tp = count / pageSize - } - data.PageSize = pageSize - data.Data = list - data.Page = pageNum - data.PageCount = tp - data.TotalSize = count + //var tp int64 + //if count%pageSize > 0 { + // tp = count/pageSize + 1 + //} else { + // tp = count / pageSize + //} + ps := new(PagingStruct) + ps.List = list + ps.Total = count + data.Data = ps + //data.PageSize = pageSize + //data.Data = list + //data.Page = pageNum + //data.PageCount = tp + //data.TotalSize = count return data } diff --git a/model/index.go b/model/index.go index 350ac62..cbc1958 100644 --- a/model/index.go +++ b/model/index.go @@ -35,6 +35,8 @@ func New(driveName, dsn string) { &MatterService{}, &MatterServiceParams{}, &MatterVersion{}, + &Model{}, + &ModelVersion{}, &Node{}, &OriginalData{}, &Owner{},