Browse Source

update

master
dengbiao 3 months ago
parent
commit
cb4f0a3831
2 changed files with 23 additions and 1 deletions
  1. +22
    -0
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  2. +1
    -1
      app/db/db_meal_label.go

+ 22
- 0
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go View File

@@ -504,6 +504,8 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) {
now := time.Now() now := time.Now()
mealLabelDb := db.MealLabelDb{} mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(req.EnterpriseId) mealLabelDb.Set(req.EnterpriseId)

var nowIds map[int]bool
for _, v := range req.MealLabelList { for _, v := range req.MealLabelList {
if v.Id != 0 { if v.Id != 0 {
mealLabel, err := mealLabelDb.GetMealLabel(v.Id) mealLabel, err := mealLabelDb.GetMealLabel(v.Id)
@@ -518,6 +520,7 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) {
e.OutErr(c, e.ERR_DB_ORM, err.Error()) e.OutErr(c, e.ERR_DB_ORM, err.Error())
return return
} }
nowIds[v.Id] = true
} else { } else {
mealLabel := &model.MealLabel{ mealLabel := &model.MealLabel{
Name: v.Name, 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) e.OutSuc(c, "success", nil)
return return
} }


+ 1
- 1
app/db/db_meal_label.go View File

@@ -26,7 +26,7 @@ func (MealLabelDb *MealLabelDb) FindMealLabel(gradeId int, kind int32) (*[]model
return &m, nil return &m, nil
} }


func (MealLabelDb *MealLabelDb) MealLabelDeleteBySession(id interface{}) (int64, error) {
func (MealLabelDb *MealLabelDb) MealLabelDelete(id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice { if reflect.TypeOf(id).Kind() == reflect.Slice {
return MealLabelDb.Db.In("id", id).Delete(model.MealLabel{}) return MealLabelDb.Db.In("id", id).Delete(model.MealLabel{})
} else { } else {


Loading…
Cancel
Save