智慧食堂
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

hdl_enterprise.go 4.0 KiB

vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package hdl
  2. import (
  3. "applet/app/customer/lib/validate"
  4. "applet/app/customer/md"
  5. "applet/app/customer/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/enum"
  9. "applet/app/utils"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func EnterpriseList(c *gin.Context) {
  13. var req md.EnterpriseListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. if req.Limit == 0 {
  22. req.Limit = 10
  23. }
  24. if req.Page == 0 {
  25. req.Page = 10
  26. }
  27. enterprises, total, err := svc.EnterpriseList(req)
  28. if err != nil {
  29. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  30. return
  31. }
  32. e.OutSuc(c, map[string]interface{}{
  33. "list": enterprises,
  34. "total": total,
  35. "kind": []map[string]interface{}{
  36. {
  37. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(),
  38. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  39. },
  40. {
  41. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(),
  42. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  43. },
  44. {
  45. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(),
  46. "value": enum.EnterprisePvdBySelfSupportForSchool,
  47. },
  48. {
  49. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(),
  50. "value": enum.EnterprisePvdBySelfSupportForFactory,
  51. },
  52. },
  53. }, nil)
  54. return
  55. }
  56. func EnterpriseInfo(c *gin.Context) {
  57. enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
  58. enterpriseDb := db.EnterpriseDb{}
  59. enterpriseDb.Set()
  60. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  61. if err != nil {
  62. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  63. return
  64. }
  65. if enterprise == nil {
  66. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  67. return
  68. }
  69. var resp interface{}
  70. //判断单位类型
  71. switch enterprise.Kind {
  72. case enum.EnterprisePvdByCentralKitchenForSchool:
  73. err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
  74. if err != nil {
  75. e.OutErr(c, e.ERR, err.Error())
  76. return
  77. }
  78. break
  79. case enum.EnterprisePvdByNursingHome:
  80. err, resp = svc.NursingHomePackageInfo(enterpriseId)
  81. if err != nil {
  82. e.OutErr(c, e.ERR, err.Error())
  83. return
  84. }
  85. break
  86. }
  87. sysCfgDb := db.SysCfgDb{}
  88. sysCfgDb.Set()
  89. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, enum.NursingHomeReserveMealTime, enum.NursingHomeCancelMealTime)
  90. e.OutSuc(c, map[string]interface{}{
  91. "info": resp,
  92. "set_center": res,
  93. "enterprise_kind_list": []map[string]interface{}{
  94. {
  95. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForSchool),
  96. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  97. },
  98. {
  99. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForFactory),
  100. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  101. },
  102. {
  103. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForSchool),
  104. "value": enum.EnterprisePvdBySelfSupportForSchool,
  105. },
  106. {
  107. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForFactory),
  108. "value": enum.EnterprisePvdBySelfSupportForFactory,
  109. },
  110. {
  111. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByNursingHome),
  112. "value": enum.EnterprisePvdByNursingHome,
  113. },
  114. },
  115. }, nil)
  116. return
  117. }
  118. func SchoolBelowGrade(c *gin.Context) {
  119. enterpriseId := c.DefaultQuery("enterprise_id", "")
  120. gradeDb := db.GradeDb{}
  121. gradeDb.Set(utils.StrToInt(enterpriseId))
  122. gradeList, err := gradeDb.FindGrade()
  123. if err != nil {
  124. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  125. return
  126. }
  127. e.OutSuc(c, map[string]interface{}{
  128. "list": gradeList,
  129. }, nil)
  130. return
  131. }
  132. func SchoolGradeBelowClass(c *gin.Context) {
  133. gradeId := c.DefaultQuery("grade_id", "")
  134. classDb := db.ClassDb{}
  135. classDb.Set(utils.StrToInt(gradeId))
  136. classList, err := classDb.FindClass()
  137. if err != nil {
  138. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  139. return
  140. }
  141. e.OutSuc(c, map[string]interface{}{
  142. "list": classList,
  143. }, nil)
  144. return
  145. }