mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Refactor code
This commit is contained in:
parent
9b76407193
commit
7e88621aa1
@ -288,7 +288,6 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri
|
||||
log.NewError(req.CommID.OperationID, "CheckAccess false ", req.CommID.OpUserID, req.CommID.FromUserID)
|
||||
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
err := imdb.DeleteSingleFriendInfo(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "DeleteSingleFriendInfo failed", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
|
@ -14,10 +14,10 @@ import "time"
|
||||
//}
|
||||
//open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
|
||||
type Friend struct {
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primaryKey;"`
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;"`
|
||||
Remark string `gorm:"column:remark"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
FriendUserID string `gorm:"column:friend_user_id;primaryKey;"`
|
||||
FriendUserID string `gorm:"column:friend_user_id;primary_key;"`
|
||||
AddSource int32 `gorm:"column:add_source"`
|
||||
OperatorUserID string `gorm:"column:operator_user_id"`
|
||||
Ex string `gorm:"column:ex"`
|
||||
@ -159,7 +159,7 @@ type User struct {
|
||||
//}
|
||||
// open_im_sdk.BlackInfo(BlackUserInfo) != imdb.Black (BlockUserID)
|
||||
type Black struct {
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primaryKey;"`
|
||||
OwnerUserID string `gorm:"column:owner_user_id;primaryKey;size:256"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
BlockUserID string `gorm:"column:block_user_id;primaryKey;"`
|
||||
AddSource int32 `gorm:"column:add_source"`
|
||||
|
@ -39,7 +39,10 @@ func GetFriendListByUserID(OwnerUserID string) ([]db.Friend, error) {
|
||||
return nil, err
|
||||
}
|
||||
var friends []db.Friend
|
||||
var x db.Friend
|
||||
x.OwnerUserID = OwnerUserID
|
||||
err = dbConn.Table("friend").Where("owner_user_id=?", OwnerUserID).Find(&friends).Error
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2,9 +2,25 @@ package utils
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
"runtime"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// copy a by b b->a
|
||||
func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error) {
|
||||
return copier.Copy(a, b)
|
||||
}
|
||||
|
||||
func Wrap(err error, message string) error {
|
||||
return errors.Wrap(err, "==> "+printCallerNameAndLine()+message)
|
||||
}
|
||||
|
||||
func WithMessage(err error, message string) error {
|
||||
return errors.WithMessage(err, "==> "+printCallerNameAndLine()+message)
|
||||
}
|
||||
|
||||
func printCallerNameAndLine() string {
|
||||
pc, _, line, _ := runtime.Caller(2)
|
||||
return runtime.FuncForPC(pc).Name() + "()@" + strconv.Itoa(line) + ": "
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user