-
Notifications
You must be signed in to change notification settings - Fork 43
/
property.go
53 lines (47 loc) · 1.21 KB
/
property.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
package api
import (
"github.com/baetyl/baetyl-cloud/v2/common"
"github.com/baetyl/baetyl-cloud/v2/models"
)
func (api *API) GetProperty(c *common.Context) (interface{}, error) {
return api.Prop.GetProperty(c.Param("name"))
}
func (api *API) CreateProperty(c *common.Context) (interface{}, error) {
property := &models.Property{}
err := c.LoadBody(property)
if err != nil {
return nil, err
}
return nil, api.Prop.CreateProperty(property)
}
func (api *API) DeleteProperty(c *common.Context) (interface{}, error) {
return nil, api.Prop.DeleteProperty(c.Param("name"))
}
func (api *API) ListProperty(c *common.Context) (interface{}, error) {
params := &models.Filter{}
if err := c.Bind(params); err != nil {
return nil, err
}
properties, err := api.Prop.ListProperty(params)
if err != nil {
return nil, err
}
count, err := api.Prop.CountProperty(params.Name)
if err != nil {
return nil, err
}
return models.MisData{
Count: count,
Rows: properties,
}, nil
}
func (api *API) UpdateProperty(c *common.Context) (interface{}, error) {
property := &models.Property{
Name: c.Param("name"),
}
err := c.LoadBody(property)
if err != nil {
return nil, err
}
return nil, api.Prop.UpdateProperty(property)
}