diff --git a/dao/video.go b/dao/video.go index 6747325..c850abf 100644 --- a/dao/video.go +++ b/dao/video.go @@ -115,6 +115,23 @@ func FindVideoListsByAuthID(auth_id int) []Video { return videos } +// 管理员查找视频,可查找所有视频 +func FindVideoByID2(id int) []Video { + var videos []Video + var err error + if proto.Config.SERVER_SQL_LOG { + res := DB.Debug().Raw("select * from videos where id = ?", id).Scan(&videos) + err = res.Error + } else { + res := DB.Raw("select * from videos where id = ?", id).Scan(&videos) + err = res.Error + } + if err != nil { + return nil + } + return videos +} + func FindVideoListByTime(auth_id int, startTime, endTime string) []Video { var videos []Video if proto.Config.SERVER_SQL_LOG { diff --git a/service/videoService.go b/service/videoService.go index 508598e..06028da 100644 --- a/service/videoService.go +++ b/service/videoService.go @@ -21,7 +21,12 @@ func GetWillDelVideoList(id int) []dao.Video { func GetVideoList(auth_id, id int, start, end, hour string) []dao.Video { if id > 0 { - return []dao.Video{dao.FindVideoByID(id, auth_id)} + user := dao.FindUserByID2(auth_id) + if user.Role == "admin" { + return dao.FindVideoByID2(id) //可根据id查找视频 + } else { + return []dao.Video{dao.FindVideoByID(id, auth_id)} + } } if start == "" { return dao.FindVideoListsByAuthID(auth_id)