From 9b130ae56c012fc0a15feb2b584ce46d3002b301 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 12 Aug 2022 19:13:08 +0800 Subject: [PATCH] fix log --- internal/cms_api/admin/admin.go | 8 ++++---- internal/cms_api/router.go | 6 +++--- pkg/cms_api_struct/admin.go | 6 +++--- pkg/cms_api_struct/common.go | 9 +++++++-- pkg/common/db/model_struct.go | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/internal/cms_api/admin/admin.go b/internal/cms_api/admin/admin.go index 81a900d02..4583afd2c 100644 --- a/internal/cms_api/admin/admin.go +++ b/internal/cms_api/admin/admin.go @@ -64,7 +64,7 @@ func AdminLogin(c *gin.Context) { reqPb pbAdmin.AdminLoginReq ) if err := c.BindJSON(&req); err != nil { - log.NewInfo("0", utils.GetSelfFuncName(), err.Error()) + log.NewError("0", utils.GetSelfFuncName(), err.Error()) openIMHttp.RespHttp200(c, constant.ErrArgs, nil) return } @@ -95,7 +95,7 @@ func AddUserRegisterAddFriendIDList(c *gin.Context) { resp apiStruct.AddUserRegisterAddFriendIDListResponse ) if err := c.BindJSON(&req); err != nil { - log.NewInfo("0", utils.GetSelfFuncName(), err.Error()) + log.NewError("0", utils.GetSelfFuncName(), err.Error()) openIMHttp.RespHttp200(c, constant.ErrArgs, nil) return } @@ -123,7 +123,7 @@ func ReduceUserRegisterAddFriendIDList(c *gin.Context) { resp apiStruct.ReduceUserRegisterAddFriendIDListResponse ) if err := c.BindJSON(&req); err != nil { - log.NewInfo("0", utils.GetSelfFuncName(), err.Error()) + log.NewError("0", utils.GetSelfFuncName(), err.Error()) openIMHttp.RespHttp200(c, constant.ErrArgs, nil) return } @@ -151,7 +151,7 @@ func GetUserRegisterAddFriendIDList(c *gin.Context) { resp apiStruct.GetUserRegisterAddFriendIDListResponse ) if err := c.BindJSON(&req); err != nil { - log.NewInfo("0", utils.GetSelfFuncName(), err.Error()) + log.NewError("0", utils.GetSelfFuncName(), err.Error()) openIMHttp.RespHttp200(c, constant.ErrArgs, nil) return } diff --git a/internal/cms_api/router.go b/internal/cms_api/router.go index 8edca6deb..b21e4a2a0 100644 --- a/internal/cms_api/router.go +++ b/internal/cms_api/router.go @@ -21,9 +21,9 @@ func NewGinRouter() *gin.Engine { { adminRouterGroup.POST("/login", admin.AdminLogin) adminRouterGroup.Use(middleware.JWTAuth()) - adminRouterGroup.POST("/add_user_register_add_friend_ID", admin.AddUserRegisterAddFriendIDList) - adminRouterGroup.POST("/reduce_user_register_reduce_friend_ID", admin.ReduceUserRegisterAddFriendIDList) - adminRouterGroup.POST("/get_user_register_reduce_friend_ID_list", admin.GetUserRegisterAddFriendIDList) + adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList) + adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList) + adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList) } r2 := router.Group("") r2.Use(middleware.JWTAuth()) diff --git a/pkg/cms_api_struct/admin.go b/pkg/cms_api_struct/admin.go index 504ed02cc..81048719b 100644 --- a/pkg/cms_api_struct/admin.go +++ b/pkg/cms_api_struct/admin.go @@ -22,7 +22,7 @@ type AddUserRegisterAddFriendIDListResponse struct { type ReduceUserRegisterAddFriendIDListRequest struct { OperationID string `json:"operationID" binding:"required"` UserIDList []string `json:"userIDList" binding:"required"` - Operation int32 `json:"operation" binding:"required"` + Operation int32 `json:"operation"` } type ReduceUserRegisterAddFriendIDListResponse struct { @@ -30,10 +30,10 @@ type ReduceUserRegisterAddFriendIDListResponse struct { type GetUserRegisterAddFriendIDListRequest struct { OperationID string `json:"operationID" binding:"required"` - RequestPagination + RequestPaginationBody } type GetUserRegisterAddFriendIDListResponse struct { - Users []*server_api_params.UserInfo `json:"Users"` + Users []*server_api_params.UserInfo `json:"users"` ResponsePagination } diff --git a/pkg/cms_api_struct/common.go b/pkg/cms_api_struct/common.go index 7d160f543..812e212ab 100644 --- a/pkg/cms_api_struct/common.go +++ b/pkg/cms_api_struct/common.go @@ -5,7 +5,12 @@ type RequestPagination struct { ShowNumber int `form:"show_number" binding:"required"` } +type RequestPaginationBody struct { + PageNumber int `json:"pageNumber" binding:"required"` + ShowNumber int `json:"showNumber" binding:"required"` +} + type ResponsePagination struct { CurrentPage int `json:"current_number" binding:"required"` - ShowNumber int `json:"show_number" binding:"required"` -} \ No newline at end of file + ShowNumber int `json:"show_number" binding:"required"` +} diff --git a/pkg/common/db/model_struct.go b/pkg/common/db/model_struct.go index bc33aec7e..c6e2dbf92 100644 --- a/pkg/common/db/model_struct.go +++ b/pkg/common/db/model_struct.go @@ -327,7 +327,7 @@ func (AppVersion) TableName() string { } type RegisterAddFriend struct { - UserID string `gorm:"column:user_id;size:64"` + UserID string `gorm:"column:user_id;primary_key;size:64"` } func (RegisterAddFriend) TableName() string {