mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-11 04:25:59 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
@@ -17,7 +17,7 @@ type UserRegisterReq struct {
|
||||
}
|
||||
|
||||
type UserTokenInfo struct {
|
||||
UserID string `json:"secret"`
|
||||
UserID string `json:"userID"`
|
||||
Token string `json:"token"`
|
||||
ExpiredTime int64 `json:"expiredTime"`
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ type GroupRequest struct {
|
||||
type User struct {
|
||||
UserID string `gorm:"column:user_id;primaryKey;"`
|
||||
Nickname string `gorm:"column:name"`
|
||||
FaceUrl string `gorm:"column:icon"`
|
||||
FaceUrl string `gorm:"column:face_url"`
|
||||
Gender int32 `gorm:"column:gender"`
|
||||
PhoneNumber string `gorm:"column:phone_number"`
|
||||
Birth string `gorm:"column:birth"`
|
||||
|
||||
@@ -25,6 +25,8 @@ func FriendDBCopyOpenIM(dst *open_im_sdk.FriendInfo, src imdb.Friend) {
|
||||
if user != nil {
|
||||
utils.CopyStructFields(dst.FriendUser, user)
|
||||
}
|
||||
dst.CreateTime = src.CreateTime.Unix()
|
||||
dst.FriendUser.CreateTime = user.CreateTime.Unix()
|
||||
}
|
||||
|
||||
//
|
||||
@@ -34,6 +36,8 @@ func FriendRequestOpenIMCopyDB(dst *imdb.FriendRequest, src open_im_sdk.FriendRe
|
||||
|
||||
func FriendRequestDBCopyOpenIM(dst *open_im_sdk.FriendRequest, src imdb.FriendRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.CreateTime = src.CreateTime.Unix()
|
||||
dst.HandleTime = src.HandleTime.Unix()
|
||||
}
|
||||
|
||||
func GroupOpenIMCopyDB(dst *imdb.Group, src open_im_sdk.GroupInfo) {
|
||||
@@ -47,6 +51,7 @@ func GroupDBCopyOpenIM(dst *open_im_sdk.GroupInfo, src imdb.Group) {
|
||||
dst.OwnerUserID = user.UserID
|
||||
}
|
||||
dst.MemberCount = imdb.GetGroupMemberNumByGroupID(src.GroupID)
|
||||
dst.CreateTime = src.CreateTime.Unix()
|
||||
}
|
||||
|
||||
func GroupMemberOpenIMCopyDB(dst *imdb.GroupMember, src open_im_sdk.GroupMemberFullInfo) {
|
||||
@@ -62,6 +67,7 @@ func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src imdb.Grou
|
||||
}
|
||||
dst.AppMangerLevel = 1
|
||||
}
|
||||
dst.JoinTime = src.JoinTime.Unix()
|
||||
}
|
||||
|
||||
func GroupRequestOpenIMCopyDB(dst *imdb.GroupRequest, src open_im_sdk.GroupRequest) {
|
||||
@@ -70,6 +76,8 @@ func GroupRequestOpenIMCopyDB(dst *imdb.GroupRequest, src open_im_sdk.GroupReque
|
||||
|
||||
func GroupRequestDBCopyOpenIM(dst *open_im_sdk.GroupRequest, src imdb.GroupRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.ReqTime = src.ReqTime.Unix()
|
||||
dst.HandleTime = src.HandledTime.Unix()
|
||||
}
|
||||
|
||||
func UserOpenIMCopyDB(dst *imdb.User, src open_im_sdk.UserInfo) {
|
||||
@@ -78,6 +86,7 @@ func UserOpenIMCopyDB(dst *imdb.User, src open_im_sdk.UserInfo) {
|
||||
|
||||
func UserDBCopyOpenIM(dst *open_im_sdk.UserInfo, src imdb.User) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.CreateTime = src.CreateTime.Unix()
|
||||
}
|
||||
|
||||
func BlackOpenIMCopyDB(dst *imdb.Black, src open_im_sdk.BlackInfo) {
|
||||
|
||||
@@ -2,11 +2,14 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/jinzhu/copier"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// copy a by b b->a
|
||||
func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error) {
|
||||
return copier.Copy(a, b)
|
||||
|
||||
at := reflect.TypeOf(a)
|
||||
av := reflect.ValueOf(a)
|
||||
bt := reflect.TypeOf(b)
|
||||
@@ -34,6 +37,7 @@ func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error
|
||||
|
||||
for i := 0; i < len(_fields); i++ {
|
||||
name := _fields[i]
|
||||
|
||||
f := av.Elem().FieldByName(name)
|
||||
bValue := bv.FieldByName(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user