智慧食堂
Você não pode selecionar mais de 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.

166 linhas
4.5 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.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
  38. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  39. },
  40. {
  41. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
  42. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  43. },
  44. {
  45. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
  46. "value": enum.EnterpriseKindBySelfSupportForSchool,
  47. },
  48. {
  49. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
  50. "value": enum.EnterpriseKindBySelfSupportForFactory,
  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. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  72. err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
  73. if err != nil {
  74. e.OutErr(c, e.ERR, err.Error())
  75. return
  76. }
  77. }
  78. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  79. err, resp = svc.NursingHomePackageInfo(enterpriseId)
  80. if err != nil {
  81. e.OutErr(c, e.ERR, err.Error())
  82. return
  83. }
  84. }
  85. sysCfgDb := db.SysCfgDb{}
  86. sysCfgDb.Set()
  87. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, enum.NursingHomeReserveMealTime, enum.NursingHomeCancelMealTime)
  88. e.OutSuc(c, map[string]interface{}{
  89. "info": resp,
  90. "set_center": res,
  91. "enterprise_kind_list": []map[string]interface{}{
  92. {
  93. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
  94. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  95. },
  96. {
  97. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
  98. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  99. },
  100. {
  101. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
  102. "value": enum.EnterpriseKindBySelfSupportForSchool,
  103. },
  104. {
  105. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
  106. "value": enum.EnterpriseKindBySelfSupportForFactory,
  107. },
  108. {
  109. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
  110. "value": enum.EnterpriseKindByNursingHome,
  111. },
  112. },
  113. "user_identity_cert_type_list": []map[string]interface{}{
  114. {
  115. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForIdCard),
  116. "value": enum.UserIdentityCertTypeForIdCard,
  117. },
  118. {
  119. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForStudentId),
  120. "value": enum.UserIdentityCertTypeForStudentId,
  121. },
  122. //{
  123. // "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport),
  124. // "value": enum.UserIdentityCertTypeForPassport,
  125. //},
  126. },
  127. }, nil)
  128. return
  129. }
  130. func SchoolBelowGrade(c *gin.Context) {
  131. enterpriseId := c.DefaultQuery("enterprise_id", "")
  132. gradeDb := db.GradeDb{}
  133. gradeDb.Set(utils.StrToInt(enterpriseId))
  134. gradeList, err := gradeDb.FindGrade()
  135. if err != nil {
  136. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  137. return
  138. }
  139. e.OutSuc(c, map[string]interface{}{
  140. "list": gradeList,
  141. }, nil)
  142. return
  143. }
  144. func SchoolGradeBelowClass(c *gin.Context) {
  145. gradeId := c.DefaultQuery("grade_id", "")
  146. classDb := db.ClassDb{}
  147. classDb.Set(utils.StrToInt(gradeId))
  148. classList, err := classDb.FindClass()
  149. if err != nil {
  150. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  151. return
  152. }
  153. e.OutSuc(c, map[string]interface{}{
  154. "list": classList,
  155. }, nil)
  156. return
  157. }