tidy code

This commit is contained in:
wenxu12345 2021-12-28 16:36:02 +08:00
parent 508ccf4f9c
commit f43e1a1018
2 changed files with 4 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/auth" rpc "Open_IM/pkg/proto/auth"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -26,7 +27,7 @@ func UserRegister(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
return return
} }
req := &rpc.UserRegisterReq{} req := &rpc.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
utils.CopyStructFields(*req.UserInfo, params) utils.CopyStructFields(*req.UserInfo, params)
req.OperationID = params.OperationID req.OperationID = params.OperationID
log.NewInfo(req.OperationID, "UserRegister args ", req.String()) log.NewInfo(req.OperationID, "UserRegister args ", req.String())

View File

@ -8,8 +8,8 @@ import (
// copy a by b b->a // copy a by b b->a
func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error) { func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error) {
copier.Copy(&a, &b) return copier.Copy(&a, &b)
return nil
at := reflect.TypeOf(a) at := reflect.TypeOf(a)
av := reflect.ValueOf(a) av := reflect.ValueOf(a)
bt := reflect.TypeOf(b) bt := reflect.TypeOf(b)