智慧食堂
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

169 linhas
4.7 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. platform := c.GetHeader("platform")
  28. enterprises, total, err := svc.EnterpriseList(req, platform)
  29. if err != nil {
  30. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  31. return
  32. }
  33. e.OutSuc(c, map[string]interface{}{
  34. "list": enterprises,
  35. "total": total,
  36. "kind": []map[string]interface{}{
  37. {
  38. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
  39. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  40. },
  41. {
  42. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
  43. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  44. },
  45. {
  46. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
  47. "value": enum.EnterpriseKindBySelfSupportForSchool,
  48. },
  49. {
  50. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
  51. "value": enum.EnterpriseKindBySelfSupportForFactory,
  52. },
  53. },
  54. }, nil)
  55. return
  56. }
  57. func EnterpriseInfo(c *gin.Context) {
  58. enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
  59. enterpriseDb := db.EnterpriseDb{}
  60. enterpriseDb.Set()
  61. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  62. if err != nil {
  63. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  64. return
  65. }
  66. if enterprise == nil {
  67. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  68. return
  69. }
  70. var resp interface{}
  71. //判断单位类型
  72. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  73. err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
  74. if err != nil {
  75. e.OutErr(c, e.ERR, err.Error())
  76. return
  77. }
  78. }
  79. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  80. err, resp = svc.NursingHomePackageInfo(enterpriseId)
  81. if err != nil {
  82. e.OutErr(c, e.ERR, err.Error())
  83. return
  84. }
  85. }
  86. sysCfgDb := db.SysCfgDb{}
  87. sysCfgDb.Set()
  88. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime,
  89. enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, enum.CentralKitchenForSchoolCancelMealTimeForLunch, enum.CentralKitchenForSchoolCancelMealTimeForDinner)
  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.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
  96. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  97. },
  98. {
  99. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
  100. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  101. },
  102. {
  103. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
  104. "value": enum.EnterpriseKindBySelfSupportForSchool,
  105. },
  106. {
  107. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
  108. "value": enum.EnterpriseKindBySelfSupportForFactory,
  109. },
  110. {
  111. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
  112. "value": enum.EnterpriseKindByNursingHome,
  113. },
  114. },
  115. "user_identity_cert_type_list": []map[string]interface{}{
  116. {
  117. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForIdCard),
  118. "value": enum.UserIdentityCertTypeForIdCard,
  119. },
  120. {
  121. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForStudentId),
  122. "value": enum.UserIdentityCertTypeForStudentId,
  123. },
  124. //{
  125. // "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport),
  126. // "value": enum.UserIdentityCertTypeForPassport,
  127. //},
  128. },
  129. }, nil)
  130. return
  131. }
  132. func SchoolBelowGrade(c *gin.Context) {
  133. enterpriseId := c.DefaultQuery("enterprise_id", "")
  134. gradeDb := db.GradeDb{}
  135. gradeDb.Set(utils.StrToInt(enterpriseId))
  136. gradeList, err := gradeDb.FindGrade()
  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": gradeList,
  143. }, nil)
  144. return
  145. }
  146. func SchoolGradeBelowClass(c *gin.Context) {
  147. gradeId := c.DefaultQuery("grade_id", "")
  148. classDb := db.ClassDb{}
  149. classDb.Set(utils.StrToInt(gradeId))
  150. classList, err := classDb.FindClass()
  151. if err != nil {
  152. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  153. return
  154. }
  155. e.OutSuc(c, map[string]interface{}{
  156. "list": classList,
  157. }, nil)
  158. return
  159. }