-
Notifications
You must be signed in to change notification settings - Fork 1
/
Controller.go
67 lines (55 loc) · 1.09 KB
/
Controller.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
65
66
67
package app
import (
"github.com/owenzhou/ginrbac/contracts"
"net/http"
)
//restful api 控制器接口
type IController interface {
Init(*Context)
Index(*Context)
Show(*Context)
Create(*Context)
Store(*Context)
Edit(*Context)
Update(*Context)
Destroy(*Context)
}
type Controller struct {
App contracts.IApplication
}
//初始化,在其它方法之前调用
func (ctrl *Controller) Init(c *Context) {}
func (ctrl *Controller) NotFound(c *Context) {
c.JSON(http.StatusNotFound, H{
"status": 404,
"message": "method not found",
})
}
//列表
func (ctrl *Controller) Index(c *Context) {
ctrl.NotFound(c)
}
//显示指定数据
func (ctrl *Controller) Show(c *Context) {
ctrl.NotFound(c)
}
//创建
func (ctrl *Controller) Create(c *Context) {
ctrl.NotFound(c)
}
//创建保存
func (ctrl *Controller) Store(c *Context) {
ctrl.NotFound(c)
}
//编辑
func (ctrl *Controller) Edit(c *Context) {
ctrl.NotFound(c)
}
//编辑保存
func (ctrl *Controller) Update(c *Context) {
ctrl.NotFound(c)
}
//删除指定数据
func (ctrl *Controller) Destroy(c *Context) {
ctrl.NotFound(c)
}