mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 14:42:20 +08:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package annotationsimpl
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/services/annotations"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type RepositoryImpl struct {
|
|
store store
|
|
}
|
|
|
|
func ProvideService(db db.DB, cfg *setting.Cfg) *RepositoryImpl {
|
|
return &RepositoryImpl{
|
|
store: &SQLAnnotationRepo{
|
|
cfg: cfg,
|
|
db: db,
|
|
log: log.New("annotations"),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (r *RepositoryImpl) Save(ctx context.Context, item *annotations.Item) error {
|
|
return r.store.Add(ctx, item)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Update(ctx context.Context, item *annotations.Item) error {
|
|
return r.store.Update(ctx, item)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Find(ctx context.Context, query *annotations.ItemQuery) ([]*annotations.ItemDTO, error) {
|
|
return r.store.Get(ctx, query)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Delete(ctx context.Context, params *annotations.DeleteParams) error {
|
|
return r.store.Delete(ctx, params)
|
|
}
|
|
|
|
func (r *RepositoryImpl) FindTags(ctx context.Context, query *annotations.TagsQuery) (annotations.FindTagsResult, error) {
|
|
return r.store.GetTags(ctx, query)
|
|
}
|