智慧食堂
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

143 líneas
3.6 KiB

  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. }
  80. sysCfgDb := db.SysCfgDb{}
  81. sysCfgDb.Set()
  82. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime)
  83. e.OutSuc(c, map[string]interface{}{
  84. "info": resp,
  85. "set_center": res,
  86. "enterprise_kind_list": []map[string]interface{}{
  87. {
  88. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForSchool),
  89. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  90. },
  91. {
  92. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForFactory),
  93. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  94. },
  95. {
  96. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForSchool),
  97. "value": enum.EnterprisePvdBySelfSupportForSchool,
  98. },
  99. {
  100. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForFactory),
  101. "value": enum.EnterprisePvdBySelfSupportForFactory,
  102. },
  103. },
  104. }, nil)
  105. return
  106. }
  107. func SchoolBelowGrade(c *gin.Context) {
  108. enterpriseId := c.DefaultQuery("enterprise_id", "")
  109. gradeDb := db.GradeDb{}
  110. gradeDb.Set(utils.StrToInt(enterpriseId))
  111. gradeList, err := gradeDb.FindGrade()
  112. if err != nil {
  113. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  114. return
  115. }
  116. e.OutSuc(c, map[string]interface{}{
  117. "list": gradeList,
  118. }, nil)
  119. return
  120. }
  121. func SchoolGradeBelowClass(c *gin.Context) {
  122. gradeId := c.DefaultQuery("grade_id", "")
  123. classDb := db.ClassDb{}
  124. classDb.Set(utils.StrToInt(gradeId))
  125. classList, err := classDb.FindClass()
  126. if err != nil {
  127. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  128. return
  129. }
  130. e.OutSuc(c, map[string]interface{}{
  131. "list": classList,
  132. }, nil)
  133. return
  134. }