Commit 7aa992bd by Alexander Zobnin

initial category types

parent f0816b37
package category
type Repository interface {
Save(item *Item) error
Update(item *Item) error
Delete(params *DeleteParams) error
Find(query *FindParams) ([]*Item, error)
}
var repositoryInstance Repository
func GetRepository() Repository {
return repositoryInstance
}
func SetRepository(rep Repository) {
repositoryInstance = rep
}
type FindParams struct {
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
Limit int64 `json:"limit"`
}
type DeleteParams struct {
Id int64 `json:"id"`
Name string `json:"title"`
}
type ItemType string
type Item struct {
Id int64 `json:"id"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
Name string `json:"title"`
Description string `json:"text"`
}
package sqlstore
import (
"github.com/grafana/grafana/pkg/services/category"
)
type SqlCategoryRepo struct {
}
func (r *SqlCategoryRepo) Save(item *category.Item) error {
return nil
}
func (r *SqlCategoryRepo) Update(item *category.Item) error {
return nil
}
func (r *SqlCategoryRepo) Delete(params *category.DeleteParams) error {
return nil
}
func (r *SqlCategoryRepo) Find(params *category.FindParams) ([]*category.Item, error) {
return nil, nil
}
......@@ -12,6 +12,7 @@ import (
"github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/annotations"
"github.com/grafana/grafana/pkg/services/category"
"github.com/grafana/grafana/pkg/services/sqlstore/migrations"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/setting"
......@@ -98,7 +99,9 @@ func SetEngine(engine *xorm.Engine) (err error) {
return fmt.Errorf("Sqlstore::Migration failed err: %v\n", err)
}
// Init repo instances
annotations.SetRepository(&SqlAnnotationRepo{})
category.SetRepository(&SqlCategoryRepo{})
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment