This commit is contained in:
withchao
2023-01-17 17:31:22 +08:00
parent 58866c1b41
commit 6ab9cff3c3
8 changed files with 265 additions and 143 deletions
@@ -52,7 +52,7 @@ func (b *Black) Update(ctx context.Context, blacks []*Black) (err error) {
return utils.Wrap(b.DB.Updates(&blacks).Error, "")
}
func (b *Black) Find(ctx context.Context, blacks []Black) (blackList []*Black, err error) {
func (b *Black) Find(ctx context.Context, blacks []*Black) (blackList []*Black, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "blacks", blacks, "blackList", blackList)
}()
+8 -1
View File
@@ -61,13 +61,20 @@ func (f *Friend) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, re
return utils.Wrap(f.DB.Model(f).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "")
}
func (f *Friend) Find(ctx context.Context, ownerUserID string) (friends []*Friend, err error) {
func (f *Friend) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*Friend, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
}()
return friends, utils.Wrap(f.DB.Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
}
func (f *Friend) FindFriendUserID(ctx context.Context, friendUserID string) (friends []*Friend, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends)
}()
return friends, utils.Wrap(f.DB.Where("friend_user_id = ?", friendUserID).Find(&friends).Error, "")
}
func (f *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, "friend", friend)
+4 -8
View File
@@ -33,16 +33,14 @@ func (f *FriendRequest) Create(ctx context.Context, friends []*FriendRequest) (e
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends)
}()
err = utils.Wrap(f.DB.Create(&friends).Error, "")
return err
return utils.Wrap(f.DB.Create(&friends).Error, "")
}
func (f *FriendRequest) Delete(ctx context.Context, fromUserID, toUserID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID)
}()
err = utils.Wrap(f.DB.Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Delete(&FriendRequest{}).Error, "")
return err
return utils.Wrap(f.DB.Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Delete(&FriendRequest{}).Error, "")
}
func (f *FriendRequest) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) {
@@ -63,15 +61,13 @@ func (f *FriendRequest) Find(ctx context.Context, ownerUserID string) (friends [
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
}()
err = utils.Wrap(f.DB.Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
return friends, err
return friends, utils.Wrap(f.DB.Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
}
func (f *FriendRequest) Take(ctx context.Context, fromUserID, toUserID string) (friend *FriendRequest, err error) {
friend = &FriendRequest{}
defer trace_log.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend)
err = utils.Wrap(f.DB.Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friend).Error, "")
return friend, err
return friend, utils.Wrap(f.DB.Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friend).Error, "")
}
func (f *FriendRequest) FindToUserID(ctx context.Context, toUserID string) (friends []*FriendRequest, err error) {