This commit is contained in:
withchao
2023-01-17 17:43:30 +08:00
parent 142b9386fc
commit 8e47b55ab4
4 changed files with 28 additions and 10 deletions
+14 -2
View File
@@ -4,6 +4,8 @@ import (
"Open_IM/pkg/common/db/cache"
"Open_IM/pkg/common/db/mysql"
"context"
"errors"
"gorm.io/gorm"
)
type BlackModel struct {
@@ -31,10 +33,20 @@ func (b *BlackModel) Find(ctx context.Context, blacks []*mysql.Black) (blackList
return b.db.Find(ctx, blacks)
}
func (b *BlackModel) Take(ctx context.Context, blackID string) (black *mysql.Black, err error) {
return b.db.Take(ctx, blackID)
func (b *BlackModel) Take(ctx context.Context, ownerUserID, blockUserID string) (black *mysql.Black, err error) {
return b.db.Take(ctx, ownerUserID, blockUserID)
}
func (b *BlackModel) FindByOwnerUserID(ctx context.Context, ownerUserID string) (blackList []*mysql.Black, err error) {
return b.db.FindByOwnerUserID(ctx, ownerUserID)
}
func (b *BlackModel) IsExist(ctx context.Context, ownerUserID, blockUserID string) (bool, error) {
if _, err := b.Take(ctx, ownerUserID, blockUserID); err == nil {
return true, nil
} else if errors.Is(err, gorm.ErrRecordNotFound) {
return false, nil
} else {
return false, err
}
}