mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-01 07:35:58 +08:00
errCode
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/mysql"
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BlackModel struct {
|
||||
db *relation.Black
|
||||
cache *cache.GroupCache
|
||||
}
|
||||
|
||||
func (b *BlackModel) Create(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
return b.db.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
return b.db.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) UpdateByMap(ctx context.Context, ownerUserID, blockUserID string, args map[string]interface{}) (err error) {
|
||||
return b.db.UpdateByMap(ctx, ownerUserID, blockUserID, args)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Update(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
return b.db.Update(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Find(ctx context.Context, blacks []*relation.Black) (blackList []*relation.Black, err error) {
|
||||
return b.db.Find(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Take(ctx context.Context, ownerUserID, blockUserID string) (black *relation.Black, err error) {
|
||||
return b.db.Take(ctx, ownerUserID, blockUserID)
|
||||
}
|
||||
|
||||
func (b *BlackModel) FindByOwnerUserID(ctx context.Context, ownerUserID string) (blackList []*relation.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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user