添加延迟的成功条数
This commit is contained in:
parent
debd994c17
commit
ec9fbc940b
18
dao/video.go
18
dao/video.go
|
|
@ -71,10 +71,20 @@ func FindVideoListByTime(auth_id int, startTime, endTime string) []Video {
|
||||||
return videos
|
return videos
|
||||||
}
|
}
|
||||||
|
|
||||||
func DelayVideo(id, auth_id, day int) {
|
// id 为视频id,auth_id为用户id,day为延长天数,返回修改的行数
|
||||||
DB.Debug().Exec("update video set delete_time = date_add(delete_time, interval ? day) where id = ? and auth_id = ? and isdelete=0", day, id, auth_id)
|
func DelayVideo(id, auth_id, day int) int {
|
||||||
|
res := DB.Debug().Exec("update video set delete_time = date_add(delete_time, interval ? day) where id = ? and auth_id = ? and isdelete=0", day, id, auth_id)
|
||||||
|
if res.Error != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int(res.RowsAffected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DelayAllVideo(id,day int){
|
// id 为用户id,day为延长天数,返回修改的行数
|
||||||
DB.Debug().Exec("update video set delete_time = date_add(delete_time, interval ? day) where auth_id = ? and isdelete = 0", day, id)
|
func DelayAllVideo(id, day int) int {
|
||||||
|
res := DB.Debug().Exec("update video set delete_time = date_add(delete_time, interval ? day) where auth_id = ? and isdelete = 0", day, id)
|
||||||
|
if res.Error != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int(res.RowsAffected)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,18 +161,23 @@ func GetVideoList(c *gin.Context) {
|
||||||
func DelayVideo(c *gin.Context) {
|
func DelayVideo(c *gin.Context) {
|
||||||
var delay_req delayReq
|
var delay_req delayReq
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
|
cnt := 0
|
||||||
if err := c.ShouldBind(&delay_req); err == nil {
|
if err := c.ShouldBind(&delay_req); err == nil {
|
||||||
if delay_req.Day > 30 || delay_req.Day < 1 {
|
if delay_req.Day > 30 || delay_req.Day < 1 {
|
||||||
c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟天数过大或过小", "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟天数过大或过小", "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if delay_req.Option == "all" {
|
if delay_req.Option == "all" {
|
||||||
service.DelayAllVideo(int(id.(float64)), delay_req.Day)
|
cnt = service.DelayAllVideo(int(id.(float64)), delay_req.Day)
|
||||||
}
|
}
|
||||||
if delay_req.Option == "one" {
|
if delay_req.Option == "one" {
|
||||||
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 {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟失败影响数据", "message": "failed,cnt:" + string(cnt)})
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 0, "data": "延迟成功,cnt=" + string(cnt), "message": "success cnt:" + string(cnt)})
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"code": 0,"data":"延迟成功", "message": "success"})
|
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetVideo(id, auth_id int) dao.Video {
|
func GetVideo(id, auth_id int) dao.Video {
|
||||||
|
|
@ -35,11 +35,11 @@ func GetVideoList(auth_id int, start, end string) []dao.Video {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DelayVideo(id, auth_id, day int) {
|
func DelayVideo(id, auth_id, day int) int {
|
||||||
dao.DelayVideo(id, auth_id, day)
|
return dao.DelayVideo(id, auth_id, day)
|
||||||
}
|
}
|
||||||
func DelayAllVideo(id,day int){
|
func DelayAllVideo(id, day int) int {
|
||||||
dao.DelayAllVideo(id,day)
|
return dao.DelayAllVideo(id, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateVideo(videoPath, videoName string, cameraID, authID, human, isDelete int, createTime, endTime string, fileSize int) uint {
|
func CreateVideo(videoPath, videoName string, cameraID, authID, human, isDelete int, createTime, endTime string, fileSize int) uint {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue