test_router.go
1.6 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
package routers
import (
"github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/beego/controllers"
"net/http"
"strconv"
"strings"
)
func init() {
web.Router("/TestController/PullMaterialNewest", &controllers.TestController{}, "Get:InvokPullMaterialNewest")
web.Router("/TestController/PullMaterialGroup", &controllers.TestController{}, "Get:InvokPullMaterialGroup")
web.Router("/TestController/InvokPullPrdMoNewest", &controllers.TestController{}, "Get:InvokPullPrdMoNewest")
web.Router("/test/create-device-collection", &controllers.TestController{}, "Post:CreateDeviceCollection")
web.Get("/test/cache-key/:key", func(ctx *context.Context) {
key := ctx.Input.Query(":key")
if len(key) != 0 {
keys, _ := redis.GetRedis().Keys(key).Result()
ctx.Output.SetStatus(http.StatusOK)
ctx.Output.JSON(keys, false, false)
}
})
web.Get("/test/cache/:key", func(ctx *context.Context) {
key := ctx.Input.Query(":key")
if len(key) != 0 {
value, _ := redis.GetRedis().Get(key).Result()
ctx.Output.SetStatus(http.StatusOK)
ctx.Output.Body([]byte(value))
}
})
web.Get("/test/cache/d/:key", func(ctx *context.Context) {
key := ctx.Input.Query(":key")
if len(key) != 0 && !strings.Contains(key, "*") {
value, _ := redis.GetRedis().Del(key).Result()
ctx.Output.SetStatus(http.StatusOK)
ctx.Output.Body([]byte(strconv.Itoa(int(value))))
}
})
}