From 0167e40f9ee14d5ad51b74822d90fc709d494cc2 Mon Sep 17 00:00:00 2001 From: lzh <1625167628@qq.com> Date: Tue, 24 Jun 2025 15:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E5=93=81id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index 1155f17..e34abc4 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -271,15 +271,22 @@ func GetVedioWorkDetail(req *bundle.GetVedioWorkDetailReq) (data model.CastWorkV } func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWorkLog, total int64, unconfirmed int64, err error) { - err = app.ModuleClients.BundleDB.Model(&model.CastWorkLog{}).Where(&model.CastWorkLog{ - ArtistUuid: req.ArtistUuid, - }).Where("confirmed_at = ?", 0).Count(&unconfirmed).Error + subQuery := app.ModuleClients.BundleDB. + Table("cast_work_log"). + Select("work_uuid, MAX(update_time) AS max_update_time"). + Group("work_uuid") + + err = app.ModuleClients.BundleDB. + Table("cast_work_log AS cwl"). + Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery). + Where("artist_uuid = ?", req.ArtistUuid).Where("confirmed_at = ?", 0).Count(&unconfirmed).Error if err != nil { return } - session := app.ModuleClients.BundleDB.Model(&model.CastWorkLog{}).Where(&model.CastWorkLog{ - ArtistUuid: req.ArtistUuid, - }) + session := app.ModuleClients.BundleDB. + Table("cast_work_log AS cwl"). + Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery). + Where("artist_uuid = ?", req.ArtistUuid) err = session.Count(&total).Error if err != nil { return