[fix] page create api
This commit is contained in:
parent
b2f0f9e5e9
commit
669d94acd9
3 changed files with 14 additions and 7 deletions
|
|
@ -118,10 +118,10 @@ var dsl = []byte(`
|
|||
"in": ["$param.id", "$param.template_id", "$param.route", ":context"],
|
||||
"out": { "status": 200, "type": "application/json" }
|
||||
},{
|
||||
"path": "/:id/page/create/:template_id",
|
||||
"path": "/:id/page/create/:template_id/*route",
|
||||
"method": "POST",
|
||||
"process": "sui.Page.Create",
|
||||
"in": ["$param.id", "$param.template_id", ":payload", ":context"],
|
||||
"in": ["$param.id", "$param.template_id", "$param.route", ":context", ":payload"],
|
||||
"out": { "status": 200, "type": "application/json" }
|
||||
},{
|
||||
"path": "/:id/page/exist/:template_id/*route",
|
||||
|
|
|
|||
|
|
@ -530,17 +530,19 @@ func PageCreate(process *process.Process) interface{} {
|
|||
process.ValidateArgNums(3)
|
||||
sui := get(process)
|
||||
templateID := process.ArgsString(1)
|
||||
payload := process.ArgsMap(2, map[string]interface{}{})
|
||||
route := process.ArgsString(2)
|
||||
payload := process.ArgsMap(4, map[string]interface{}{})
|
||||
|
||||
tmpl, err := sui.GetTemplate(templateID)
|
||||
if err != nil {
|
||||
exception.New(err.Error(), 500).Throw()
|
||||
}
|
||||
|
||||
route, ok := payload["route"].(string)
|
||||
if !ok {
|
||||
exception.New("the route is required", 400).Throw()
|
||||
// Get the route from payload
|
||||
if v, ok := payload["route"].(string); ok {
|
||||
route = v
|
||||
}
|
||||
|
||||
title := route
|
||||
if v, ok := payload["title"].(string); ok {
|
||||
title = v
|
||||
|
|
|
|||
|
|
@ -314,7 +314,12 @@ func TestPageCreate(t *testing.T) {
|
|||
|
||||
load(t)
|
||||
defer clean()
|
||||
|
||||
defer func() {
|
||||
_, err := process.New("sui.page.remove", "demo", "tech-blue", "/unit-test").Exec()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
// test demo
|
||||
p, err := process.Of("sui.page.create", "demo", "tech-blue", "/unit-test")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue