修复redis设置option问题
This commit is contained in:
parent
f48850bcc2
commit
05d76a08bc
|
|
@ -86,7 +86,7 @@ func SetUpVideoGroup(router *gin.Engine) {
|
||||||
func GetWillDelVideoList(c *gin.Context) {
|
func GetWillDelVideoList(c *gin.Context) {
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
videos := service.GetWillDelVideoList(int(id.(float64)))
|
videos := service.GetWillDelVideoList(int(id.(float64)))
|
||||||
c.JSON(http.StatusOK, gin.H{"videos": videos, "code": 0, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"videos": videos, "code": proto.SuccessCode, "message": "success"})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ func UpdateVideo(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "update video failed", "code": proto.OperationFailed, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "update video failed", "code": proto.OperationFailed, "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success", "data": "update success"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": "update success"})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ func CreateVideo(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "create video failed", "code": proto.DataNotFound, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "create video failed", "code": proto.DataNotFound, "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"id": id, "code": 0, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"id": id, "code": proto.SuccessCode, "message": "success"})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +158,7 @@ func GetVideoList(c *gin.Context) {
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
if err := c.ShouldBind(&gvl_req); err == nil {
|
if err := c.ShouldBind(&gvl_req); err == nil {
|
||||||
videos := service.GetVideoList(int(id.(float64)), gvl_req.StartTime, gvl_req.EndTime, gvl_req.Hour)
|
videos := service.GetVideoList(int(id.(float64)), gvl_req.StartTime, gvl_req.EndTime, gvl_req.Hour)
|
||||||
c.JSON(http.StatusOK, gin.H{"data": videos, "code": 0, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"data": videos, "code": proto.SuccessCode, "message": "success"})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||||
}
|
}
|
||||||
|
|
@ -181,12 +181,12 @@ func DelayVideo(c *gin.Context) {
|
||||||
cnt = service.DelayVideo(delay_req.ID, int(id.(float64)), delay_req.Day)
|
cnt = service.DelayVideo(delay_req.ID, int(id.(float64)), delay_req.Day)
|
||||||
}
|
}
|
||||||
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)), "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)+"-"+id.(string)+"-option", string(str))
|
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
||||||
c.JSON(http.StatusOK, gin.H{"code": 0, "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)})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||||
|
|
@ -202,8 +202,8 @@ func DeleteVideo(c *gin.Context) {
|
||||||
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")}
|
||||||
str, _ := json.Marshal(data)
|
str, _ := json.Marshal(data)
|
||||||
worker.PushRedisList(user.(string)+"-"+id.(string)+"-option", string(str))
|
worker.PushRedisList(user.(string)+"-"+strconv.Itoa(int(id.(float64)))+"-option", string(str))
|
||||||
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.ParameterError, "message": "failed"})
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ func QuashOption(c *gin.Context) {
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
user, _ := c.Get("username")
|
user, _ := c.Get("username")
|
||||||
if err := c.ShouldBind(&video_req); err == nil {
|
if err := c.ShouldBind(&video_req); err == nil {
|
||||||
res := worker.PopRedisList(user.(string) + "-" + id.(string) + "-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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue