/
aibase_api.go
64 lines (58 loc) · 1.17 KB
/
aibase_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package apis
import (
"github.com/gin-gonic/gin"
"github.com/hootrhino/rulex/component/aibase"
common "github.com/hootrhino/rulex/component/rulex_api_server/common"
"github.com/hootrhino/rulex/typex"
)
/*
*
* AiBase
*
*/
func AiBase(c *gin.Context, ruleEngine typex.RuleX) {
uuid, _ := c.GetQuery("uuid")
if uuid == "" {
c.JSON(common.HTTP_OK, common.OkWithData(aibase.ListAi()))
return
}
if ai := aibase.GetAi(uuid); ai != nil {
c.JSON(common.HTTP_OK, common.OkWithData(ai))
return
}
c.JSON(common.HTTP_OK, common.Error("ai base not found:"+uuid))
}
/*
*
* 删除
*
*/
func DeleteAiBase(c *gin.Context, ruleEngine typex.RuleX) {
uuid, _ := c.GetQuery("uuid")
if ai := aibase.GetAi(uuid); ai != nil {
err := aibase.RemoveAi(uuid)
if err != nil {
c.JSON(common.HTTP_OK, common.Error400(err))
return
}
c.JSON(common.HTTP_OK, common.Ok())
return
}
c.JSON(common.HTTP_OK, common.Error("ai base not found:"+uuid))
}
/*
*
* Create
*
*/
func CreateAiBase(c *gin.Context, ruleEngine typex.RuleX) {
c.JSON(common.HTTP_OK, common.Ok())
}
/*
*
* 更新
*
*/
func UpdateAiBase(c *gin.Context, ruleEngine typex.RuleX) {
c.JSON(common.HTTP_OK, common.Ok())
}