Error code standardization

This commit is contained in:
skiffer-git 2023-01-13 14:39:23 +08:00
parent 29c1bb86d8
commit 8e8ee2b968
2 changed files with 10 additions and 9 deletions

View File

@ -58,9 +58,9 @@ func (*Friend) Find(ctx context.Context, ownerUserID string) (friends []*Friend,
return friends, err
}
func (*Friend) Take(ctx context.Context, ownerUserID, friendUserID string) (group *Group, err error) {
group = &Group{}
defer trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "group", *group)
err = utils.Wrap(FriendDB.Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(group).Error, "")
return group, err
func (*Friend) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *Friend, err error) {
friend = &Friend{}
defer trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "group", *friend)
err = utils.Wrap(FriendDB.Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "")
return friend, err
}

View File

@ -56,10 +56,11 @@ func (*User) Find(ctx context.Context, userIDs []string) (users []*User, err err
return users, err
}
func (*User) Take(ctx context.Context, userIDs []string) (users []*User, err error) {
func (*User) Take(ctx context.Context, userID string) (user *User, err error) {
user = &User{}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDs", userIDs, "users", users)
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "user", *user)
}()
err = utils.Wrap(userDB.Where("user_id in (?)", userIDs).Take(&users).Error, "")
return users, err
err = utils.Wrap(userDB.Where("user_id = ?", userID).Take(&user).Error, "")
return user, err
}