/
handler.go
executable file
·66 lines (53 loc) · 1.5 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
package site
import (
"github.com/ch3nnn/webstack-go/configs"
"github.com/ch3nnn/webstack-go/internal/pkg/core"
"github.com/ch3nnn/webstack-go/internal/pkg/hash"
"github.com/ch3nnn/webstack-go/internal/repository/mysql"
"github.com/ch3nnn/webstack-go/internal/repository/redis"
"github.com/ch3nnn/webstack-go/internal/services/site"
"go.uber.org/zap"
)
var _ Handler = (*handler)(nil)
type Handler interface {
i()
// Create 创建/编辑网站列表
// @Tags API.site
// @Router /api/site [post]
Create() core.HandlerFunc
// Delete 删除网站列表
// @Tags API.site
// @Router /api/site/{id} [delete]
Delete() core.HandlerFunc
// UpdateUsed 更新网站为启用/禁用
// @Tags API.site
// @Router /api/site/used [patch]
UpdateUsed() core.HandlerFunc
// List 网站列表
// @Tags API.site
// @Router /api/site [get]
List() core.HandlerFunc
// CategoryList 新增网站-分类目录列表
// @Tags API.site
// @Router /api/site/category_list [get]
CategoryList() core.HandlerFunc
// UpdateSite 编辑网站
// @Tags API.site
// @Router /api/site [put]
UpdateSite() core.HandlerFunc
}
type handler struct {
logger *zap.Logger
cache redis.Repo
hashids hash.Hash
siteService site.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),
siteService: site.New(db, cache),
}
}
func (h *handler) i() {}