From d6f3d8f974731171d6ea1ea7bd45110b199f2590 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 10 Sep 2024 18:56:10 +0800 Subject: [PATCH] 1 --- .../hdl_central_kitchen_for_school.go | 20 +++++++++++-------- .../hdl_self_support_for_school.go | 19 ++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go index 5227d31..aea7c61 100644 --- a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go @@ -1773,16 +1773,20 @@ func CentralKitchenForSchoolClassSort(c *gin.Context) { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } + classDb := db.ClassDb{} classDb.Set(0) - class, err := classDb.FindClassById(ClassSortArgs.Ids) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - for k, v := range *class { - v.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + (1000 - k) - _, err1 := classDb.ClassUpdate(&v, "sort") + for k, v := range ClassSortArgs.Ids { + class, err := classDb.GetClass(v) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if class == nil { + continue + } + class.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + k + _, err1 := classDb.ClassUpdate(class, "sort") if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return diff --git a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go index 7d49790..af604a5 100644 --- a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go @@ -637,14 +637,17 @@ func SelfSupportForSchoolClassSort(c *gin.Context) { } classDb := db.ClassDb{} classDb.Set(0) - class, err := classDb.FindClassById(ClassSortArgs.Ids) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - for k, v := range *class { - v.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + (1000 - k) - _, err1 := classDb.ClassUpdate(&v, "sort") + for k, v := range ClassSortArgs.Ids { + class, err := classDb.GetClass(v) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if class == nil { + continue + } + class.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + k + _, err1 := classDb.ClassUpdate(class, "sort") if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return