diff --git a/dao/video.go b/dao/video.go index e8ac14c..d23b7f8 100644 --- a/dao/video.go +++ b/dao/video.go @@ -19,6 +19,12 @@ type Video struct { FileSize int `gorm:"column:file_size"` } +func FindWillDelVideoList(id int) []Video { + var videos []Video + DB.Debug().Where("auth_id = ?", id).Where("delete_time<=now()").Find(&videos) + return videos +} + func CreateVideo(videoPath, videoName string, cameraID, authID, human, isDelete int, createTime, endTime string, fileSize int) uint { video := Video{VideoPath: videoPath, VideoName: videoName, CameraID: cameraID, AuthId: authID, Human: human, IsDelete: isDelete, CreateTime: createTime, EndTime: endTime, FileSize: fileSize} res := DB.Debug().Create(&video) diff --git a/handler/video.go b/handler/video.go index 320e03d..94d2135 100644 --- a/handler/video.go +++ b/handler/video.go @@ -67,12 +67,21 @@ type delayReq struct { func SetUpVideoGroup(router *gin.Engine) { videoGroup := router.Group("/video") videoGroup.POST("/get_video_list", GetVideoList) + videoGroup.POST("/will_del_video_list", GetWillDelVideoList) videoGroup.POST("/create", CreateVideo) videoGroup.GET("/mp4", GetVideo) videoGroup.POST("/delay", DelayVideo) videoGroup.POST("/delete", DeleteVideo) videoGroup.POST("/update", UpdateVideo) } + +func GetWillDelVideoList(c *gin.Context) { + id, _ := c.Get("id") + videos := service.GetWillDelVideoList(int(id.(float64))) + c.JSON(http.StatusOK, gin.H{"videos": videos, "code": 0, "message": "success"}) + +} + func UpdateVideo(c *gin.Context) { var video_req videoUpdateReq user_id, _ := c.Get("id") diff --git a/service/videoService.go b/service/videoService.go index d006eec..f6923d9 100644 --- a/service/videoService.go +++ b/service/videoService.go @@ -9,6 +9,10 @@ func GetVideo(id, auth_id int) dao.Video { return dao.FindVideoByID(id, auth_id) } +func GetWillDelVideoList(id int) []dao.Video { + return dao.FindWillDelVideoList(id) +} + func GetVideoList(auth_id int, start, end string) []dao.Video { if start == "" { return dao.FindVideoListsByAuthID(auth_id)