添加视频id查询管理员方式

This commit is contained in:
junleea 2024-12-21 18:47:47 +08:00
parent ec0c152032
commit 8689f78181
2 changed files with 23 additions and 1 deletions

View File

@ -115,6 +115,23 @@ func FindVideoListsByAuthID(auth_id int) []Video {
return videos 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 { func FindVideoListByTime(auth_id int, startTime, endTime string) []Video {
var videos []Video var videos []Video
if proto.Config.SERVER_SQL_LOG { if proto.Config.SERVER_SQL_LOG {

View File

@ -21,7 +21,12 @@ func GetWillDelVideoList(id int) []dao.Video {
func GetVideoList(auth_id, id int, start, end, hour string) []dao.Video { func GetVideoList(auth_id, id int, start, end, hour string) []dao.Video {
if id > 0 { 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 == "" { if start == "" {
return dao.FindVideoListsByAuthID(auth_id) return dao.FindVideoListsByAuthID(auth_id)