智慧食堂
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.

118 lines
3.0 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. }
  47. e.OutSuc(c, map[string]interface{}{
  48. "info": resp,
  49. "kind": []map[string]interface{}{
  50. {
  51. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(),
  52. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  53. },
  54. {
  55. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(),
  56. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  57. },
  58. {
  59. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(),
  60. "value": enum.EnterprisePvdBySelfSupportForSchool,
  61. },
  62. {
  63. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(),
  64. "value": enum.EnterprisePvdBySelfSupportForFactory,
  65. },
  66. },
  67. }, nil)
  68. return
  69. }
  70. func UserIdentityList(c *gin.Context) {
  71. var req md.EnterpriseUserListReq
  72. err := c.ShouldBindJSON(&req)
  73. if err != nil {
  74. err = validate.HandleValidateErr(err)
  75. err1 := err.(e.E)
  76. e.OutErr(c, err1.Code, err1.Error())
  77. return
  78. }
  79. enterpriseDb := db.EnterpriseDb{}
  80. enterpriseDb.Set()
  81. enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
  82. if err != nil {
  83. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  84. return
  85. }
  86. if enterprise == nil {
  87. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  88. return
  89. }
  90. var resp interface{}
  91. switch enterprise.Kind {
  92. case enum.EnterprisePvdByCentralKitchenForSchool:
  93. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  94. if err != nil {
  95. e.OutErr(c, e.ERR, err.Error())
  96. return
  97. }
  98. break
  99. case enum.EnterprisePvdByCentralKitchenForFactory:
  100. break
  101. case enum.EnterprisePvdBySelfSupportForSchool:
  102. resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
  103. if err != nil {
  104. e.OutErr(c, e.ERR, err.Error())
  105. return
  106. }
  107. break
  108. case enum.EnterprisePvdBySelfSupportForFactory:
  109. break
  110. }
  111. e.OutSuc(c, resp, nil)
  112. return
  113. }