智慧食堂
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

hdl_enterprise.go 3.4 KiB

1年前
1年前
1年前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. }