From f0560e4cf1d49954b4c3a5afffdeb07eb646ba41 Mon Sep 17 00:00:00 2001 From: majun <3060162534@qq.com> Date: Fri, 20 Dec 2024 11:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- link_homework/internal/logic/homework/homework.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/link_homework/internal/logic/homework/homework.go b/link_homework/internal/logic/homework/homework.go index e5470b2..2491b42 100644 --- a/link_homework/internal/logic/homework/homework.go +++ b/link_homework/internal/logic/homework/homework.go @@ -12,7 +12,6 @@ import ( "link_homework/internal/model/do" "link_homework/internal/model/entity" "link_homework/internal/service" - "sort" ) type ( @@ -41,7 +40,7 @@ func (s *sHomework) GetHomeworkList(ctx context.Context, pageNo int, pageSize in } // 如果Redis中没有数据,查询数据库 - err = dao.ActivityInteractiveGroup.Ctx(ctx).With(entity.Live{}).Order("start_date desc, end_date desc").Page(pageNo, pageSize).Scan(&homeworkList) + err = dao.ActivityInteractiveGroup.Ctx(ctx).With(entity.Live{}).OrderDesc("created_at").Page(pageNo, pageSize).Scan(&homeworkList) err = g.DB("cms").Model("fx_article").Where("id", gdb.ListItemValuesUnique(homeworkList, "ArticleId")).ScanList(&homeworkList, "Article", "id:ArticleId") homeworkList = UpdateHomework(ctx, homeworkList) if err != nil { @@ -71,20 +70,6 @@ func UpdateHomework(ctx context.Context, homeworkList []*entity.ActivityInteract } } - // 对 homeworkList 进行排序 - sort.Slice(homeworkList, func(i, j int) bool { - if homeworkList[i].Status != homeworkList[j].Status { - return homeworkList[i].Status < homeworkList[j].Status - } - if homeworkList[i].Status == 0 { - return homeworkList[i].StartDate.Before(homeworkList[j].StartDate) - } - if homeworkList[i].Status == 1 { - return homeworkList[i].EndDate.Before(homeworkList[j].EndDate) - } - return false - }) - return homeworkList }