添加获取要删除的视频记录。

This commit is contained in:
lijun 2024-05-21 15:48:20 +08:00
parent c4b3eeb394
commit 8227718ee2
3 changed files with 19 additions and 0 deletions

View File

@ -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)

View File

@ -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")

View File

@ -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)