Skip to content

Commit

Permalink
+ API
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Sep 28, 2021
1 parent d87086a commit f78d9e2
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 31 deletions.
8 changes: 8 additions & 0 deletions global/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ func watchEngine(from string) {
script := getFile(root, file)
gou.LoadAPI(string(script.Content), "xiang."+script.Name) // Reload
log.Printf("API %s 已重新加载完毕", "xiang."+script.Name)

// 打印最新API信息
api := gou.APIs["xiang."+script.Name]
log.Printf("%s(%d)", api.Name, len(api.HTTP.Paths))
for _, p := range api.HTTP.Paths {
log.Println(p.Method, filepath.Join("/api", api.HTTP.Group, p.Path), "\tprocess:", p.Process)
}

} else if op == "remove" || op == "rename" {
name := "xiang." + getFileName(root, file)
if _, has := gou.APIs[name]; has {
Expand Down
2 changes: 1 addition & 1 deletion table/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func apiDefaultWhere(model *gou.Model, withs map[string]gou.With, name string, p
}
}

// apiDefaultSetting 接口默认值
// apiDefaultSetting 数据表格配置默认值
func apiDefaultSetting(table *Table) API {
return API{
Name: "setting",
Expand Down
30 changes: 0 additions & 30 deletions xiang/apis/sys.http.json

This file was deleted.

109 changes: 109 additions & 0 deletions xiang/apis/table.http.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"name": "数据表格接口",
"version": "1.0.0",
"description": "数据表格接口API",
"group": "xiang/table",
"guard": "bearer-jwt",
"paths": [
{
"path": "/:name/search",
"method": "GET",
"process": "xiang.table.Search",
"in": ["$param.name", ":query-param", "$query.page", "$query.pagesize"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/find/:id",
"method": "GET",
"process": "xiang.table.Find",
"in": ["$param.name", "$param.id"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/save/:id",
"method": "POST",
"process": "xiang.table.Save",
"in": ["$param.name", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/delete/:id",
"method": "POST",
"process": "xiang.table.Delete",
"in": ["$param.name", "$param.id"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/insert",
"method": "POST",
"process": "xiang.table.Insert",
"in": ["$param.name", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/delete/where",
"method": "POST",
"process": "xiang.table.DeleteWhere",
"in": ["$param.name", ":query-param", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/delete/in",
"method": "POST",
"process": "xiang.table.DeleteIn",
"in": ["$param.name", "$query.ids", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/update/where",
"method": "POST",
"process": "xiang.table.UpdateWhere",
"in": ["$param.name", ":query-param", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/update/in",
"method": "POST",
"process": "xiang.table.UpdateIn",
"in": ["$param.name", "$query.ids", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/setting",
"method": "GET",
"process": "xiang.table.Setting",
"in": ["$param.name"],
"out": {
"status": 200,
"type": "application/json"
}
}
]
}
20 changes: 20 additions & 0 deletions xiang/apis/xiang.http.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "系统接口",
"version": "1.0.0",
"description": "系统接口API",
"group": "xiang",
"guard": "bearer-jwt",
"paths": [
{
"path": "/ping",
"method": "GET",
"guard": "-",
"process": "xiang.ping",
"in": [],
"out": {
"status": 200,
"type": "application/json"
}
}
]
}

0 comments on commit f78d9e2

Please sign in to comment.