智慧食堂
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

svc_enterprise.go 2.1 KiB

1 rok temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package svc
  2. import (
  3. "applet/app/customer/md"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. )
  7. func EnterpriseList(req md.EnterpriseListReq) (m []model.Enterprise, total int64, err error) {
  8. eg := db.Db.Where("1=1")
  9. if req.Name != "" {
  10. eg.And("name like ?", "%"+req.Name+"%")
  11. }
  12. total, err = eg.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
  13. if err != nil {
  14. return
  15. }
  16. return
  17. }
  18. func CentralKitchenForSchoolInfo(enterpriseId int) (err error, resp md.CentralKitchenForSchoolInfoResp) {
  19. //1、查询`enterprise`
  20. enterpriseDb := db.EnterpriseDb{}
  21. enterpriseDb.Set()
  22. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  23. if err != nil {
  24. return
  25. }
  26. resp.Name = enterprise.Name
  27. resp.Memo = enterprise.Memo
  28. resp.Kind = enterprise.Kind
  29. resp.State = enterprise.State
  30. //2、查询`central_kitchen_for_school_with_spec`
  31. centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
  32. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  33. spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
  34. if err != nil {
  35. return
  36. }
  37. if spec != nil {
  38. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  39. resp.IsOpenLunch = spec.IsOpenLunch
  40. resp.IsOpenDinner = spec.IsOpenDinner
  41. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  42. resp.BreakfastUnitPriceForTeacher = spec.BreakfastUnitPriceForTeacher
  43. resp.LunchUnitPrice = spec.LunchUnitPrice
  44. resp.LunchUnitPriceForTeacher = spec.LunchUnitPriceForTeacher
  45. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  46. resp.DinnerUnitPriceForTeacher = spec.DinnerUnitPriceForTeacher
  47. }
  48. //3、查询`central_kitchen_for_school_set`
  49. centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{}
  50. centralKitchenForSchoolSetDb.Set(enterpriseId)
  51. set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet()
  52. if err != nil {
  53. return
  54. }
  55. if set != nil {
  56. resp.IsOpenTeacherReportMeal = set.IsOpenTeacherReportMeal
  57. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  58. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  59. resp.IsOpenReportMealForSemester = set.IsOpenReportMealForSemester
  60. }
  61. return
  62. }