mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
add support for fetching appSettings by appId
This commit is contained in:
parent
fd52320460
commit
423eca6e7d
@ -1,6 +1,13 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrAppSettingNotFound = errors.New("AppSetting not found")
|
||||
)
|
||||
|
||||
type AppSettings struct {
|
||||
Id int64
|
||||
@ -33,3 +40,9 @@ type GetAppSettingsQuery struct {
|
||||
OrgId int64
|
||||
Result []*AppSettings
|
||||
}
|
||||
|
||||
type GetAppSettingByAppIdQuery struct {
|
||||
AppId string
|
||||
OrgId int64
|
||||
Result *AppSettings
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
func init() {
|
||||
bus.AddHandler("sql", GetAppSettings)
|
||||
bus.AddHandler("sql", GetAppSettingByAppId)
|
||||
bus.AddHandler("sql", UpdateAppSettings)
|
||||
}
|
||||
|
||||
@ -19,6 +20,18 @@ func GetAppSettings(query *m.GetAppSettingsQuery) error {
|
||||
return sess.Find(&query.Result)
|
||||
}
|
||||
|
||||
func GetAppSettingByAppId(query *m.GetAppSettingByAppIdQuery) error {
|
||||
appSetting := m.AppSettings{OrgId: query.OrgId, AppId: query.AppId}
|
||||
has, err := x.Get(&appSetting)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if has == false {
|
||||
return m.ErrAppSettingNotFound
|
||||
}
|
||||
query.Result = &appSetting
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateAppSettings(cmd *m.UpdateAppSettingsCmd) error {
|
||||
return inTransaction2(func(sess *session) error {
|
||||
var app m.AppSettings
|
||||
|
Loading…
Reference in New Issue
Block a user