|
|
@@ -504,6 +504,8 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
|
now := time.Now() |
|
|
|
mealLabelDb := db.MealLabelDb{} |
|
|
|
mealLabelDb.Set(req.EnterpriseId) |
|
|
|
|
|
|
|
var nowIds map[int]bool |
|
|
|
for _, v := range req.MealLabelList { |
|
|
|
if v.Id != 0 { |
|
|
|
mealLabel, err := mealLabelDb.GetMealLabel(v.Id) |
|
|
@@ -518,6 +520,7 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
nowIds[v.Id] = true |
|
|
|
} else { |
|
|
|
mealLabel := &model.MealLabel{ |
|
|
|
Name: v.Name, |
|
|
@@ -536,6 +539,25 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
labels, err := mealLabelDb.FindMealLabel(req.GradeId, req.Kind) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
var needDelIds []int |
|
|
|
for _, v := range *labels { |
|
|
|
if !nowIds[v.Id] { |
|
|
|
needDelIds = append(needDelIds, v.Id) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(needDelIds) > 0 { |
|
|
|
_, err = mealLabelDb.MealLabelDelete(needDelIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|