redis输出key error,video quash修复
This commit is contained in:
parent
eddd38414c
commit
6ffabcdbcc
|
|
@ -183,7 +183,7 @@ func DelayVideo(c *gin.Context) {
|
||||||
if cnt == 0 {
|
if cnt == 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.OperationFailed, "data": "延迟失败数据", "message": "failed,cnt:" + strconv.Itoa(cnt)})
|
c.JSON(http.StatusOK, gin.H{"code": proto.OperationFailed, "data": "延迟失败数据", "message": "failed,cnt:" + strconv.Itoa(cnt)})
|
||||||
} else {
|
} else {
|
||||||
data := map[string]interface{}{"auth_id": int(id.(float64)), "delay_time": time.Now().Format("2006-01-02 15:04:05"), "delay_day": delay_req.Day, "option": delay_req.Option, "id": delay_req.ID}
|
data := map[string]interface{}{"auth_id": int(id.(float64)), "method": "delay", "delay_time": time.Now().Format("2006-01-02 15:04:05"), "delay_day": delay_req.Day, "option": delay_req.Option, "id": delay_req.ID}
|
||||||
str, _ := json.Marshal(data)
|
str, _ := json.Marshal(data)
|
||||||
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "data": "延迟成功,影响记录:" + strconv.Itoa(cnt), "message": "success cnt:" + strconv.Itoa(cnt)})
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "data": "延迟成功,影响记录:" + strconv.Itoa(cnt), "message": "success cnt:" + strconv.Itoa(cnt)})
|
||||||
|
|
@ -200,7 +200,7 @@ func DeleteVideo(c *gin.Context) {
|
||||||
if err := c.ShouldBind(&video_req); err == nil {
|
if err := c.ShouldBind(&video_req); err == nil {
|
||||||
res := service.DeleteVideo(video_req.ID, int(id.(float64)))
|
res := service.DeleteVideo(video_req.ID, int(id.(float64)))
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
data := map[string]interface{}{"id": video_req.ID, "auth_id": int(id.(float64)), "delete_time": time.Now().Format("2006-01-02 15:04:05")}
|
data := map[string]interface{}{"id": video_req.ID, "auth_id": int(id.(float64)), "delete_time": time.Now().Format("2006-01-02 15:04:05"), "method": "delete"}
|
||||||
str, _ := json.Marshal(data)
|
str, _ := json.Marshal(data)
|
||||||
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
||||||
|
|
@ -213,25 +213,20 @@ func DeleteVideo(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func QuashOption(c *gin.Context) {
|
func QuashOption(c *gin.Context) {
|
||||||
var video_req VideoDelReq
|
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
user, _ := c.Get("username")
|
user, _ := c.Get("username")
|
||||||
if err := c.ShouldBind(&video_req); err == nil {
|
res := worker.PopRedisList(user.(string) + "-" + strconv.Itoa(int(id.(float64))) + "-option")
|
||||||
res := worker.PopRedisList(user.(string) + "-" + strconv.Itoa(int(id.(float64))) + "-option")
|
if res != "" {
|
||||||
if res != "" {
|
var retrievedData map[string]interface{}
|
||||||
var retrievedData map[string]interface{}
|
err2 := json.Unmarshal([]byte(res), &retrievedData)
|
||||||
err2 := json.Unmarshal([]byte(res), &retrievedData)
|
if err2 != nil {
|
||||||
if err2 != nil {
|
code, msg := service.QuashVideo(int(id.(float64)), retrievedData)
|
||||||
code, msg := service.QuashVideo(int(id.(float64)), retrievedData)
|
c.JSON(http.StatusOK, gin.H{"code": code, "message": msg, "data": msg})
|
||||||
c.JSON(http.StatusOK, gin.H{"code": code, "message": msg, "data": msg})
|
|
||||||
} else {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": err2, "data": "2"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": "redis data not found", "data": "error"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": err2, "data": "2"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": "redis data not found", "data": "error"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ func GetRedis(key string) string {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
val, err := redisClient.Get(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
val, err := redisClient.Get(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error getting key: %v", err)
|
fmt.Println(key, " Error getting key: %v", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
|
|
@ -160,7 +160,7 @@ func PopRedisList(key string) string {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
val, err := redisClient.RPop(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
val, err := redisClient.RPop(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error reading from Redis: %v", err)
|
fmt.Println(key, " Error reading from Redis: %v", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue