智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 regels
1.5 KiB

  1. package svc
  2. import (
  3. "applet/app/admin/md"
  4. "applet/app/db"
  5. "applet/app/enum"
  6. )
  7. func NursingHomeInfo(enterpriseId int) (err error, resp md.NursingHomeInfoResp) {
  8. //1、查询`enterprise`
  9. enterpriseDb := db.EnterpriseDb{}
  10. enterpriseDb.Set()
  11. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  12. if err != nil {
  13. return
  14. }
  15. resp.Name = enterprise.Name
  16. resp.Memo = enterprise.Memo
  17. resp.Kind = enum.EnterprisePvd(enterprise.Kind).String()
  18. resp.State = enum.EnterpriseState(enterprise.State).String()
  19. //2、查询`nursing_home_with_spec`
  20. nursingHomeForSchoolWithSpec := db.NursingHomeWithSpec{}
  21. nursingHomeForSchoolWithSpec.Set(enterpriseId)
  22. spec, err := nursingHomeForSchoolWithSpec.GetNursingHomeWithSpec()
  23. if err != nil {
  24. return
  25. }
  26. if spec != nil {
  27. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  28. resp.IsOpenLunch = spec.IsOpenLunch
  29. resp.IsOpenDinner = spec.IsOpenDinner
  30. }
  31. //3、查询`nursing_home_set`
  32. nursingHomeSetDb := db.NursingHomeSetDb{}
  33. nursingHomeSetDb.Set(enterpriseId)
  34. set, err := nursingHomeSetDb.GetNursingHomeSet()
  35. if err != nil {
  36. return
  37. }
  38. if set != nil {
  39. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  40. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  41. resp.IsOpenReportMealForYear = set.IsOpenReportMealForYear
  42. }
  43. //4、统计 用户 数量
  44. userIdentityDb := db.UserIdentityDb{}
  45. userIdentityDb.Set(0)
  46. resp.UserIdentityNums, err = userIdentityDb.CountUserIdentityForEnterprise(enterpriseId, enum.UserIdentityForNursingHome)
  47. if err != nil {
  48. return
  49. }
  50. return
  51. }