package svc import ( "applet/app/customer/md" "applet/app/db" "applet/app/db/model" ) func EnterpriseList(req md.EnterpriseListReq) (m []model.Enterprise, total int64, err error) { eg := db.Db.Where("1=1") if req.Name != "" { eg.And("name like ?", "%"+req.Name+"%") } total, err = eg.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) if err != nil { return } return } func CentralKitchenForSchoolInfo(enterpriseId int) (err error, resp md.CentralKitchenForSchoolInfoResp) { //1、查询`enterprise` enterpriseDb := db.EnterpriseDb{} enterpriseDb.Set() enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) if err != nil { return } resp.Name = enterprise.Name resp.Memo = enterprise.Memo resp.Kind = enterprise.Kind resp.State = enterprise.State //2、查询`central_kitchen_for_school_with_spec` centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} centralKitchenForSchoolWithSpec.Set(enterpriseId) spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() if err != nil { return } if spec != nil { resp.IsOpenBreakfast = spec.IsOpenBreakfast resp.IsOpenLunch = spec.IsOpenLunch resp.IsOpenDinner = spec.IsOpenDinner resp.BreakfastUnitPrice = spec.BreakfastUnitPrice resp.BreakfastUnitPriceForTeacher = spec.BreakfastUnitPriceForTeacher resp.LunchUnitPrice = spec.LunchUnitPrice resp.LunchUnitPriceForTeacher = spec.LunchUnitPriceForTeacher resp.DinnerUnitPrice = spec.DinnerUnitPrice resp.DinnerUnitPriceForTeacher = spec.DinnerUnitPriceForTeacher } //3、查询`central_kitchen_for_school_set` centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{} centralKitchenForSchoolSetDb.Set(enterpriseId) set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet() if err != nil { return } if set != nil { resp.IsOpenTeacherReportMeal = set.IsOpenTeacherReportMeal resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth resp.IsOpenReportMealForSemester = set.IsOpenReportMealForSemester } return }