From 8689f7818150c128b3d39ae7ab4c4859ad80f6f3 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sat, 21 Dec 2024 18:47:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=86=E9=A2=91id=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=AE=A1=E7=90=86=E5=91=98=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/video.go | 17 +++++++++++++++++ service/videoService.go | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) 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)