forked from xinliangnote/go-gin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.go
81 lines (65 loc) · 1.86 KB
/
handler.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package menu
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/repository/mysql"
"github.com/xinliangnote/go-gin-api/internal/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/hash"
"go.uber.org/zap"
)
var _ Handler = (*handler)(nil)
type Handler interface {
i()
// Create 创建/编辑菜单
// @Tags API.menu
// @Router /api/menu [post]
Create() core.HandlerFunc
// Detail 菜单详情
// @Tags API.menu
// @Router /api/menu/{id} [get]
Detail() core.HandlerFunc
// Delete 删除菜单
// @Tags API.menu
// @Router /api/menu/{id} [delete]
Delete() core.HandlerFunc
// UpdateUsed 更新菜单为启用/禁用
// @Tags API.menu
// @Router /api/menu/used [patch]
UpdateUsed() core.HandlerFunc
// UpdateSort 更新菜单排序
// @Tags API.menu
// @Router /api/menu/sort [patch]
UpdateSort() core.HandlerFunc
// List 菜单列表
// @Tags API.menu
// @Router /api/menu [get]
List() core.HandlerFunc
// CreateAction 创建功能权限
// @Tags API.menu
// @Router /api/menu_action [post]
CreateAction() core.HandlerFunc
// ListAction 功能权限列表
// @Tags API.menu
// @Router /api/menu_action [get]
ListAction() core.HandlerFunc
// DeleteAction 删除功能权限
// @Tags API.menu
// @Router /api/menu_action/{id} [delete]
DeleteAction() core.HandlerFunc
}
type handler struct {
logger *zap.Logger
cache redis.Repo
hashids hash.Hash
menuService menu.Service
}
func New(logger *zap.Logger, db mysql.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
cache: cache,
hashids: hash.New(configs.Get().HashIds.Secret, configs.Get().HashIds.Length),
menuService: menu.New(db, cache),
}
}
func (h *handler) i() {}