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