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