package repository import ( "backend/pkg/library/mongo" "backend/pkg/permission/domain" "backend/pkg/permission/domain/entity" "backend/pkg/permission/domain/repository" "context" "errors" "github.com/zeromicro/go-zero/core/stores/cache" "github.com/zeromicro/go-zero/core/stores/mon" "go.mongodb.org/mongo-driver/v2/bson" ) type PermissionRepositoryParam struct { Conf *mongo.Conf CacheConf cache.CacheConf DBOpts []mon.Option CacheOpts []cache.Option } type PermissionRepository struct { DB mongo.DocumentDBWithCacheUseCase } func NewAccountRepository(param PermissionRepositoryParam) repository.PermissionRepository { e := entity.Permission{} documentDB, err := mongo.MustDocumentDBWithCache( param.Conf, e.CollectionName(), param.CacheConf, param.DBOpts, param.CacheOpts, ) if err != nil { panic(err) } return &PermissionRepository{ DB: documentDB, } } func (repo *PermissionRepository) FindOne(ctx context.Context, id string) (*entity.Permission, error) { var data entity.Permission rk := domain.GetPermissionIDRedisKey(id) oid, err := bson.ObjectIDFromHex(id) if err != nil { return nil, ErrInvalidObjectID } err = repo.DB.FindOne(ctx, rk, &data, bson.M{"_id": oid}) switch { case err == nil: return &data, nil case errors.Is(err, mon.ErrNotFound): return nil, ErrNotFound default: return nil, err } } func (repo *PermissionRepository) GetByName(ctx context.Context, name string) (*entity.Permission, error) { //TODO implement me panic("implement me") } func (repo *PermissionRepository) GetByNames(ctx context.Context, names []string) ([]*entity.Permission, error) { //TODO implement me panic("implement me") } func (repo *PermissionRepository) GetByHTTP(ctx context.Context, path, method string) (*entity.Permission, error) { //TODO implement me panic("implement me") } func (repo *PermissionRepository) List(ctx context.Context, filter repository.PermissionFilter) ([]*entity.Permission, error) { //TODO implement me panic("implement me") } func (repo *PermissionRepository) ListActive(ctx context.Context) ([]*entity.Permission, error) { //TODO implement me panic("implement me") } func (repo *PermissionRepository) GetChildren(ctx context.Context, parentID int64) ([]*entity.Permission, error) { //TODO implement me panic("implement me") }