|
|
@@ -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 |
|
|
|