This commit is contained in:
Max 2021-09-28 10:52:01 +08:00
parent d87086a575
commit f78d9e26cb
5 changed files with 138 additions and 31 deletions

View file

@ -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 {

View file

@ -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",

View file

@ -1,30 +0,0 @@
{
"name": "系统接口",
"version": "1.0.0",
"description": "系统接口API",
"group": "sys",
"guard": "bearer-jwt",
"paths": [
{
"path": "/info",
"method": "GET",
"guard": "-",
"process": "models.user.Find",
"in": ["$param.id", ":params"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/find/:id",
"method": "GET",
"process": "models.user.Find",
"in": ["$param.id", ":params"],
"out": {
"status": 200,
"type": "application/json"
}
}
]
}

109
xiang/apis/table.http.json Normal file
View file

@ -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"
}
}
]
}

View file

@ -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"
}
}
]
}