Tag.go
2.44 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package Api
import (
"github.com/aarongao/tools"
"github.com/gin-gonic/gin"
"gopkg.in/mgo.v2/bson"
"letu/DB"
)
// @Title 标签列表
// @Description 标签列表
// @Accept json
// @Produce json
// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}"
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /Tags? [get]
func AllTag(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
c.Header("Access-Control-Allow-Credentials", "true")
var Stags []*DB.STag
DB.CTags.Find(bson.M{}).All(&Stags)
if Stags == nil {
c.JSON(200, tools.ResponseError{
1,
"空",
})
} else {
c.JSON(200, tools.ResponseSeccess{
0,
Stags,
})
}
}
// @Title 创建标签
// @Description 创建标签
// @Accept json
// @Produce json
// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}"
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /CreateTag? [post]
func CreateTag(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
c.Header("Access-Control-Allow-Credentials", "true")
var Stags []*DB.STag
DB.CTags.Find(bson.M{}).All(&Stags)
if Stags == nil {
c.JSON(200, tools.ResponseError{
1,
"空",
})
} else {
c.JSON(200, tools.ResponseSeccess{
0,
Stags,
})
}
}
// @Title 更新标签
// @Description 更新标签
// @Accept json
// @Produce json
// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":[{"Type":"menu","Name":"服务设施"},{"Type":"normal","Name":"不错"},{"Type":"thrilling","Name":"刺激"},{"Type":"recommend","Name":"必玩"}]}"
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /UpdateTag? [post]
func UpdateTag(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
c.Header("Access-Control-Allow-Credentials", "true")
var Stags []*DB.STag
DB.CTags.Find(bson.M{}).All(&Stags)
if Stags == nil {
c.JSON(200, tools.ResponseError{
1,
"空",
})
} else {
c.JSON(200, tools.ResponseSeccess{
0,
Stags,
})
}
}