UserService: use the UserService instead of calling sqlstore directly (#55745)
* UserService: update callers to use the UserService instead of calling sqlstore directly There is one major change hiding in this PR. UserService.Delete originally called a number of services to delete user-related records. I moved everything except the actual call to the user table, and moved those into the API. This was done to avoid dependencies cycles; many of our services depend on the user service, so the user service itself should have as few dependencies as possible.
This commit is contained in:
@@ -5,10 +5,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana/pkg/events"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type store interface {
|
||||
@@ -23,6 +25,17 @@ type store interface {
|
||||
type sqlStore struct {
|
||||
db db.DB
|
||||
dialect migrator.Dialect
|
||||
logger log.Logger
|
||||
cfg *setting.Cfg
|
||||
}
|
||||
|
||||
func ProvideStore(db db.DB, cfg *setting.Cfg) sqlStore {
|
||||
return sqlStore{
|
||||
db: db,
|
||||
dialect: db.GetDialect(),
|
||||
cfg: cfg,
|
||||
logger: log.New("user.store"),
|
||||
}
|
||||
}
|
||||
|
||||
func (ss *sqlStore) Insert(ctx context.Context, cmd *user.User) (int64, error) {
|
||||
|
||||
Reference in New Issue
Block a user