-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
184 lines (139 loc) · 7.4 KB
/
main.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package main
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
"os"
"time"
"redisManger/src/common"
"redisManger/src/dbs"
"redisManger/src/handlers"
_ "redisManger/src/models/ActionModel"
"redisManger/src/utils/myHttp"
"github.com/gin-gonic/gin"
)
func main() {
os.Mkdir("./files", os.ModePerm)
r := gin.New()
r.StaticFS("/files", http.Dir("./files"))
r.Use(common.Cors())
r.Use(common.Auth())
{
com := r.Group("/common")
com.POST("/toFile", handlers.CommonToFile)
com.POST("/toMySql", handlers.CommonInsertToMySql)
}
{
str := r.Group("/string")
str.GET("/scan", handlers.Scan)
str.DELETE("/:keys", handlers.DelByKeys)
str.POST("/", handlers.StringUpdate)
str.GET("/toFile", handlers.ToFile)
}
{
list := r.Group("/list")
list.GET("/scan", handlers.Scan)
list.GET("/get/:key", handlers.ListGetByKey)
list.DELETE("/:keys", handlers.DelByKeys)
list.POST("/", handlers.ListPost)
list.GET("/exists/:key", handlers.ListExists)
list.POST("/remove", handlers.ListRemoveValue)
list.POST("/insert", handlers.ListInsert)
}
{
set := r.Group("/set")
set.GET("/scan", handlers.Scan)
set.DELETE("/:keys", handlers.DelByKeys)
set.POST("/", handlers.SetPost)
set.GET("/get/:key", handlers.SetGetByKey)
set.POST("/remove", handlers.SetRemoveValue)
set.POST("/getCommon", handlers.SetGetCommon)
}
{
hash := r.Group("/hash")
hash.GET("/scan", handlers.Scan)
hash.DELETE("/:keys", handlers.DelByKeys)
hash.GET("/get/:key", handlers.HashGetByKey)
hash.POST("/remove", handlers.HashRemoveValue)
hash.POST("/", handlers.HashPost)
}
{
sortedSet := r.Group("/sortedSet")
sortedSet.GET("/scan", handlers.Scan)
sortedSet.DELETE("/:keys", handlers.DelByKeys)
sortedSet.GET("/get/:key", handlers.ZSetGetByKey)
sortedSet.POST("/", handlers.ZSetPost)
sortedSet.POST("/remove", handlers.ZSetRemoveValue)
}
{
geo := r.Group("/geo")
geo.GET("/scan", handlers.Scan)
geo.DELETE("/:keys", handlers.DelByKeys)
geo.POST("/", handlers.GEOPost)
}
{
bitmap := r.Group("/bitmap")
bitmap.GET("/scan", handlers.Scan)
}
{
cfg := r.Group("/config")
cfg.GET("/", handlers.Config)
cfg.POST("/", handlers.UpdateConfig)
}
r.GET("/info/", handlers.Info)
{
user := r.Group("/user")
user.POST("/login", handlers.Login)
user.POST("/check", handlers.Validate)
}
{
connect := r.Group("/connect")
connect.POST("/test", handlers.ConnectTest)
connect.POST("/save", handlers.ConnectSave)
connect.GET("/get", handlers.ConnectGet)
}
{
logs := r.Group("/logs")
logs.POST("/get", handlers.LogsGet)
}
log.Fatal(r.Run(":80"))
}
func insertData() {
type result struct {
Id string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Url string `json:"url"`
}
//dbs.Rds.FlushDB()
for i := 1; i <= 2; i++ {
_, str, _, _ := myHttp.Request("get", "https://so.csdn.net/api/v2/search?q=golang&t=all&p="+fmt.Sprintf("%d", i)+"&s=0&tm=0&lv=-1&ft=0&l=&u=&platform=pc", nil, nil, "cookie:uuid_tt_dd=10_7922026970-1592972787364-295687; _ga=GA1.2.2129730115.1592972789; dc_sid=c11f7409ea3f2db5aef3536ddfc37ea0; UN=XiaoHuLearn; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_7922026970-1592972787364-295687!5744*1*XiaoHuLearn; c_segment=7; p_uid=U110000; UserName=XiaoHuLearn; UserInfo=3835fc0946fc49ce9d469f4044fb12ba; UserToken=3835fc0946fc49ce9d469f4044fb12ba; UserNick=XiaoHuLearn; AU=F22; BT=1599741433952; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22uid_%22%3A%7B%22value%22%3A%22XiaoHuLearn%22%2C%22scope%22%3A1%7D%2C%22islogin%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%7D; SESSION=9c606e00-ee10-4840-b09b-19db2cc2d076; __gads=ID=614dc74697a7dab9-226bad5b1ac300ff:T=1598172190:RT=1598172190:R:S=ALNI_MbyjRZuyBOBFIuWuVikvv7rvU8F6g; aliyun_webUmidToken=T2gACDm43YE8Xi_zVyVECwy062DIOsRiDS29xvk-kwixqWIqiLiAp_FFEdEMVvEGEk8FwTvav7gAplJ6Hy7JSM6L; aliyun_UAToken=137#Zgc9hE9oUNqMSfZii9EFJ9zNIQk/t5SejH2dJ6AHGLJ95F8KgbfGRbgd3aENtnZQf+icxDDxTGWTRKT6Tm1QGkGpp+YheW0Ve/iSjHtgbaCfyv+NApyuiE/PYZewsdvC63Kdlsqna/3iJBrwni6NNV+6RgKJhqwWxD6+nDsJkMq++Wlm5hYRTKM5crxVBbQKHR8cI79VPGHtcnH+/pTNy6aJyTpVxl30rWS3shSzldNGzZBIRBoMKDMua6dvDIdUXBxEEnUMoQOJB3KvtGGSVOePurTA1e7KPjmcy+xdH3eWDifhMzQ7FhCWuN2cYUyJjQ6ZPsQBbDh3xzx5G581g44jJhTw6A6JJABYLqf0Lj+A0ka1pE6Z8c+kKcihksQt0qfIt76/xVWWL7vsR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4JZ3sLl2D06WZVoRWqZ1G9526KoC7G/O9iPF+8z9To7PpA3atER6wH3QLfUUbC3JfnJHR5jR+wj4oy8Jt5zTF/yU/SUetMdqplRHpYGnlToA39Mcp6jQTgNvsMcxC4hXjEKSY; c_first_ref=www.baidu.com; announcement-new=%7B%22isLogin%22%3Atrue%2C%22announcementUrl%22%3A%22https%3A%2F%2Fblog.csdn.net%2Fblogdevteam%2Farticle%2Fdetails%2F112280974%3Futm_source%3Dgonggao_0107%22%2C%22announcementCount%22%3A1%2C%22announcementExpire%22%3A249394776%7D; c_hasSub=true; dc_session_id=10_1610106432478.737991; searchHistoryArray-new=%5B%22golang%22%2C%22go%22%5D; c_utm_term=golang; c_utm_medium=distribute.pc_search_result.none-task-blog-2%7Eall%7Esobaiduweb%7Edefault-0-89917456.first_rank_v2_pc_rank_v29; log_Id_click=111; BAIDU_SSP_lcr=https://www.baidu.com/link?url=6g5WAIymblcq6VwQGcKigwARjvWwgG_-KArP45UiG3ZTADvSIrHMaCX3hY6GbAOq&wd=&eqid=8bd91e400004125a000000045ff84809; c_ref=https%3A//www.baidu.com/link; c_first_page=https%3A//blog.csdn.net/qq_39893313/article/details/106575947; c_page_id=default; dc_tos=qmm6g3; log_Id_pv=754; c_pref=https%3A//www.baidu.com/link; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1610106434,1610106590,1610106910,1610106916; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1610106916; log_Id_view=2177", "", 30)
fmt.Println(str)
var j interface{}
err := json.Unmarshal([]byte(str), &j)
if err == nil {
d := j.(map[string]interface{})["result_vos"].([]interface{})
for _, v := range d {
m := v.(map[string]interface{})
k := m["id"].(string)
r := &result{
Id: k,
Title: m["title"].(string),
Description: m["description"].(string),
Url: m["url"].(string),
}
rand.Seed(time.Now().UnixNano())
data, _ := json.Marshal(r)
dbs.Rds.Set("String_"+r.Id, string(data), time.Duration(rand.Int63()))
for key, value := range m {
dbs.Rds.LPush("List_"+r.Id, key+":"+fmt.Sprintf("%v", value))
dbs.Rds.SAdd("Set_"+r.Id, key+":"+key+":"+fmt.Sprintf("%v", value))
dbs.Rds.HSet("HSet_"+r.Id, key, value)
}
}
}
}
return
}