[add] sui setting api

This commit is contained in:
Max 2023-10-19 11:25:05 +08:00
parent 5e371f1dfb
commit 39cfeb38dd
6 changed files with 45 additions and 1 deletions

View file

@ -10,6 +10,14 @@ var dsl = []byte(`
"guard": "-", "guard": "-",
"group": "__yao/sui/v1", "group": "__yao/sui/v1",
"paths": [ "paths": [
{
"path": "/:id/setting",
"method": "GET",
"process": "sui.Setting",
"in": ["$param.id"],
"out": { "status": 200, "type": "application/json" }
},
{ {
"path": "/:id/template", "path": "/:id/template",
"method": "GET", "method": "GET",

View file

@ -15,6 +15,8 @@ import (
func init() { func init() {
process.RegisterGroup("sui", map[string]process.Handler{ process.RegisterGroup("sui", map[string]process.Handler{
"setting": Setting,
"template.get": TemplateGet, "template.get": TemplateGet,
"template.find": TemplateFind, "template.find": TemplateFind,
"template.asset": TemplateAsset, "template.asset": TemplateAsset,
@ -51,6 +53,16 @@ func init() {
}) })
} }
// Setting handle the get Template request
func Setting(process *process.Process) interface{} {
sui := get(process)
setting, err := sui.Setting()
if err != nil {
exception.New(err.Error(), 500).Throw()
}
return setting
}
// TemplateGet handle the get Template request // TemplateGet handle the get Template request
func TemplateGet(process *process.Process) interface{} { func TemplateGet(process *process.Process) interface{} {
process.ValidateArgNums(1) process.ValidateArgNums(1)

View file

@ -5,6 +5,7 @@ var SUIs = map[string]SUI{}
// SUI is the interface for the SUI // SUI is the interface for the SUI
type SUI interface { type SUI interface {
Setting() (*Setting, error)
GetTemplates() ([]ITemplate, error) GetTemplates() ([]ITemplate, error)
GetTemplate(name string) (ITemplate, error) GetTemplate(name string) (ITemplate, error)
UploadTemplate(src string, dst string) (ITemplate, error) UploadTemplate(src string, dst string) (ITemplate, error)

12
sui/core/sui.go Normal file
View file

@ -0,0 +1,12 @@
package core
// Setting the struct for the DSL
func (sui *DSL) Setting() (*Setting, error) {
return &Setting{
ID: sui.ID,
Guard: sui.Guard,
Option: map[string]interface{}{
"disableCodeEditor": false,
},
}, nil
}

View file

@ -4,10 +4,18 @@ package core
type DSL struct { type DSL struct {
ID string `json:"-"` ID string `json:"-"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Guard string `json:"guard,omitempty"`
Storage *Storage `json:"storage,omitempty"` Storage *Storage `json:"storage,omitempty"`
Public *Public `json:"public,omitempty"` Public *Public `json:"public,omitempty"`
} }
// Setting is the struct for the setting
type Setting struct {
ID string `json:"id,omitempty"`
Guard string `json:"guard,omitempty"`
Option map[string]interface{} `json:"option,omitempty"`
}
// Page is the struct for the page // Page is the struct for the page
type Page struct { type Page struct {
Route string `json:"route"` Route string `json:"route"`

View file

@ -7,7 +7,10 @@ import (
) )
// Azure is the struct for the azure sui // Azure is the struct for the azure sui
type Azure struct{ url url.URL } type Azure struct {
url url.URL
*core.DSL
}
// new create a new azure sui // new create a new azure sui
func new() (*Azure, error) { func new() (*Azure, error) {