智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 line
3.4 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. switch enterprise.Kind {
  28. case enum.EnterprisePvdByCentralKitchenForSchool:
  29. err, resp = svc.CentralKitchenForSchoolInfo(utils.StrToInt(enterpriseId))
  30. if err != nil {
  31. e.OutErr(c, e.ERR, err.Error())
  32. return
  33. }
  34. break
  35. case enum.EnterprisePvdByCentralKitchenForFactory:
  36. break
  37. case enum.EnterprisePvdBySelfSupportForSchool:
  38. err, resp = svc.SelfSupportForSchoolInfo(utils.StrToInt(enterpriseId))
  39. if err != nil {
  40. e.OutErr(c, e.ERR, err.Error())
  41. return
  42. }
  43. break
  44. case enum.EnterprisePvdBySelfSupportForFactory:
  45. break
  46. case enum.EnterprisePvdByNursingHome:
  47. err, resp = svc.NursingHomeInfo(utils.StrToInt(enterpriseId))
  48. if err != nil {
  49. e.OutErr(c, e.ERR, err.Error())
  50. return
  51. }
  52. break
  53. }
  54. e.OutSuc(c, map[string]interface{}{
  55. "info": resp,
  56. "kind": []map[string]interface{}{
  57. {
  58. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(),
  59. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  60. },
  61. {
  62. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(),
  63. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  64. },
  65. {
  66. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(),
  67. "value": enum.EnterprisePvdBySelfSupportForSchool,
  68. },
  69. {
  70. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(),
  71. "value": enum.EnterprisePvdBySelfSupportForFactory,
  72. },
  73. {
  74. "name": enum.EnterprisePvd(enum.EnterprisePvdByNursingHome).String(),
  75. "value": enum.EnterprisePvdByNursingHome,
  76. },
  77. },
  78. }, nil)
  79. return
  80. }
  81. func UserIdentityList(c *gin.Context) {
  82. var req md.EnterpriseUserListReq
  83. err := c.ShouldBindJSON(&req)
  84. if err != nil {
  85. err = validate.HandleValidateErr(err)
  86. err1 := err.(e.E)
  87. e.OutErr(c, err1.Code, err1.Error())
  88. return
  89. }
  90. enterpriseDb := db.EnterpriseDb{}
  91. enterpriseDb.Set()
  92. enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
  93. if err != nil {
  94. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  95. return
  96. }
  97. if enterprise == nil {
  98. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  99. return
  100. }
  101. var resp interface{}
  102. switch enterprise.Kind {
  103. case enum.EnterprisePvdByCentralKitchenForSchool:
  104. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  105. if err != nil {
  106. e.OutErr(c, e.ERR, err.Error())
  107. return
  108. }
  109. break
  110. case enum.EnterprisePvdByCentralKitchenForFactory:
  111. break
  112. case enum.EnterprisePvdBySelfSupportForSchool:
  113. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  114. if err != nil {
  115. e.OutErr(c, e.ERR, err.Error())
  116. return
  117. }
  118. break
  119. case enum.EnterprisePvdBySelfSupportForFactory:
  120. break
  121. case enum.EnterprisePvdByNursingHome:
  122. resp, err = svc2.EnterpriseUserListByNursingHome(req)
  123. if err != nil {
  124. e.OutErr(c, e.ERR, err.Error())
  125. return
  126. }
  127. break
  128. }
  129. e.OutSuc(c, resp, nil)
  130. return
  131. }