From 39cfeb38dd93671982ebf6524f841ef4c7b312c9 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Oct 2023 11:25:05 +0800 Subject: [PATCH 1/3] [add] sui setting api --- sui/api/api.go | 8 ++++++++ sui/api/process.go | 12 ++++++++++++ sui/core/interfaces.go | 1 + sui/core/sui.go | 12 ++++++++++++ sui/core/types.go | 8 ++++++++ sui/storages/azure/azure.go | 5 ++++- 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 sui/core/sui.go diff --git a/sui/api/api.go b/sui/api/api.go index db72029b..771b82ab 100644 --- a/sui/api/api.go +++ b/sui/api/api.go @@ -10,6 +10,14 @@ var dsl = []byte(` "guard": "-", "group": "__yao/sui/v1", "paths": [ + { + "path": "/:id/setting", + "method": "GET", + "process": "sui.Setting", + "in": ["$param.id"], + "out": { "status": 200, "type": "application/json" } + }, + { "path": "/:id/template", "method": "GET", diff --git a/sui/api/process.go b/sui/api/process.go index b3b43ff9..f3f74766 100644 --- a/sui/api/process.go +++ b/sui/api/process.go @@ -15,6 +15,8 @@ import ( func init() { process.RegisterGroup("sui", map[string]process.Handler{ + "setting": Setting, + "template.get": TemplateGet, "template.find": TemplateFind, "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 func TemplateGet(process *process.Process) interface{} { process.ValidateArgNums(1) diff --git a/sui/core/interfaces.go b/sui/core/interfaces.go index 1adc25ce..ecaaa432 100644 --- a/sui/core/interfaces.go +++ b/sui/core/interfaces.go @@ -5,6 +5,7 @@ var SUIs = map[string]SUI{} // SUI is the interface for the SUI type SUI interface { + Setting() (*Setting, error) GetTemplates() ([]ITemplate, error) GetTemplate(name string) (ITemplate, error) UploadTemplate(src string, dst string) (ITemplate, error) diff --git a/sui/core/sui.go b/sui/core/sui.go new file mode 100644 index 00000000..bc62ad83 --- /dev/null +++ b/sui/core/sui.go @@ -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 +} diff --git a/sui/core/types.go b/sui/core/types.go index fad00bb4..9a610cd3 100644 --- a/sui/core/types.go +++ b/sui/core/types.go @@ -4,10 +4,18 @@ package core type DSL struct { ID string `json:"-"` Name string `json:"name,omitempty"` + Guard string `json:"guard,omitempty"` Storage *Storage `json:"storage,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 type Page struct { Route string `json:"route"` diff --git a/sui/storages/azure/azure.go b/sui/storages/azure/azure.go index 20de84f5..ad5fccf9 100644 --- a/sui/storages/azure/azure.go +++ b/sui/storages/azure/azure.go @@ -7,7 +7,10 @@ import ( ) // 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 func new() (*Azure, error) { From da0c8ec96294176b4b0a1e9f4537b100f6a4f163 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Oct 2023 16:30:31 +0800 Subject: [PATCH 2/3] [add] block layout height --- sui/core/types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sui/core/types.go b/sui/core/types.go index 9a610cd3..a8e5d1e3 100644 --- a/sui/core/types.go +++ b/sui/core/types.go @@ -65,6 +65,7 @@ type LayoutItem struct { ID string `json:"id"` Label string `json:"label,omitempty"` Width int `json:"width,omitempty"` + Height int `json:"height,omitempty"` Blocks []LayoutItem `json:"blocks,omitempty"` } From a072a91f7073fc2d39f3e89ad56e5f2889a408bf Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Oct 2023 18:52:19 +0800 Subject: [PATCH 3/3] [add] keywords --- sui/core/types.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sui/core/types.go b/sui/core/types.go index a8e5d1e3..7621d056 100644 --- a/sui/core/types.go +++ b/sui/core/types.go @@ -62,11 +62,12 @@ type BlockLayoutItems struct { // LayoutItem is the struct for the layout it type LayoutItem struct { - ID string `json:"id"` - Label string `json:"label,omitempty"` - Width int `json:"width,omitempty"` - Height int `json:"height,omitempty"` - Blocks []LayoutItem `json:"blocks,omitempty"` + ID string `json:"id"` + Label string `json:"label,omitempty"` + Width int `json:"width,omitempty"` + Height int `json:"height,omitempty"` + Keywords []string `json:"keywords,omitempty"` + Blocks []LayoutItem `json:"blocks,omitempty"` } // Template is the struct for the template