智慧食堂
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

129 řádky
3.5 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. "applet/app/admin/md"
  5. "applet/app/admin/svc"
  6. svc2 "applet/app/admin/svc/enterprise_manage"
  7. "applet/app/db"
  8. "applet/app/e"
  9. "applet/app/enum"
  10. "applet/app/utils"
  11. "github.com/gin-gonic/gin"
  12. )
  13. func EnterpriseManageInfo(c *gin.Context) {
  14. enterpriseId := c.DefaultQuery("enterprise_id", "")
  15. enterpriseDb := db.EnterpriseDb{}
  16. enterpriseDb.Set()
  17. enterprise, err := enterpriseDb.GetEnterprise(utils.StrToInt(enterpriseId))
  18. if err != nil {
  19. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  20. return
  21. }
  22. if enterprise == nil {
  23. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  24. return
  25. }
  26. var resp interface{}
  27. //判断校企类型
  28. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  29. err, resp = svc.CentralKitchenForSchoolInfo(utils.StrToInt(enterpriseId))
  30. if err != nil {
  31. e.OutErr(c, e.ERR, err.Error())
  32. return
  33. }
  34. }
  35. if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  36. err, resp = svc.SelfSupportForSchoolInfo(utils.StrToInt(enterpriseId))
  37. if err != nil {
  38. e.OutErr(c, e.ERR, err.Error())
  39. return
  40. }
  41. }
  42. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  43. err, resp = svc.NursingHomeInfo(utils.StrToInt(enterpriseId))
  44. if err != nil {
  45. e.OutErr(c, e.ERR, err.Error())
  46. return
  47. }
  48. }
  49. e.OutSuc(c, map[string]interface{}{
  50. "info": resp,
  51. "kind": []map[string]interface{}{
  52. {
  53. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
  54. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  55. },
  56. {
  57. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
  58. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  59. },
  60. {
  61. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
  62. "value": enum.EnterpriseKindBySelfSupportForSchool,
  63. },
  64. {
  65. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
  66. "value": enum.EnterpriseKindBySelfSupportForFactory,
  67. },
  68. {
  69. "name": enum.EnterpriseKind(enum.EnterpriseKindByNursingHome).String(),
  70. "value": enum.EnterpriseKindByNursingHome,
  71. },
  72. },
  73. }, nil)
  74. return
  75. }
  76. func UserIdentityList(c *gin.Context) {
  77. var req md.EnterpriseUserListReq
  78. err := c.ShouldBindJSON(&req)
  79. if err != nil {
  80. err = validate.HandleValidateErr(err)
  81. err1 := err.(e.E)
  82. e.OutErr(c, err1.Code, err1.Error())
  83. return
  84. }
  85. enterpriseDb := db.EnterpriseDb{}
  86. enterpriseDb.Set()
  87. enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
  88. if err != nil {
  89. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  90. return
  91. }
  92. if enterprise == nil {
  93. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  94. return
  95. }
  96. var resp interface{}
  97. //判断校企类型
  98. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  99. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  100. if err != nil {
  101. e.OutErr(c, e.ERR, err.Error())
  102. return
  103. }
  104. }
  105. if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  106. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  107. if err != nil {
  108. e.OutErr(c, e.ERR, err.Error())
  109. return
  110. }
  111. }
  112. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  113. resp, err = svc2.EnterpriseUserListByNursingHome(req)
  114. if err != nil {
  115. e.OutErr(c, e.ERR, err.Error())
  116. return
  117. }
  118. }
  119. e.OutSuc(c, resp, nil)
  120. return
  121. }