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

hdl_user.go 4.5 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 UserList(c *gin.Context) {
  14. var req md.UserListReq
  15. err := c.ShouldBindJSON(&req)
  16. if err != nil {
  17. err = validate.HandleValidateErr(err)
  18. err1 := err.(e.E)
  19. e.OutErr(c, err1.Code, err1.Error())
  20. return
  21. }
  22. list, err := svc.UserList(req)
  23. if err != nil {
  24. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  25. return
  26. }
  27. e.OutSuc(c, map[string]interface{}{
  28. "list": list,
  29. "user_identity_kind_list": []map[string]interface{}{
  30. {
  31. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
  32. "value": enum.UserIdentityForCentralKitchenForStudent,
  33. },
  34. {
  35. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
  36. "value": enum.UserIdentityForCentralKitchenForTeacher,
  37. },
  38. {
  39. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
  40. "value": enum.UserIdentityForCentralKitchenForWorker,
  41. },
  42. {
  43. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
  44. "value": enum.UserIdentityForSelfSupportForStudent,
  45. },
  46. {
  47. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
  48. "value": enum.UserIdentityForSelfSupportForTeacher,
  49. },
  50. {
  51. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
  52. "value": enum.UserIdentityForSelfSupportForWorker,
  53. },
  54. },
  55. "enterprise_kind_list": []map[string]interface{}{
  56. {
  57. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForSchool),
  58. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  59. },
  60. {
  61. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForFactory),
  62. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  63. },
  64. {
  65. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForSchool),
  66. "value": enum.EnterprisePvdBySelfSupportForSchool,
  67. },
  68. {
  69. "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForFactory),
  70. "value": enum.EnterprisePvdBySelfSupportForFactory,
  71. },
  72. {
  73. "name": enum.EnterprisePvd.String(enum.EnterprisePvdByNursingHome),
  74. "value": enum.EnterprisePvdByNursingHome,
  75. },
  76. },
  77. }, nil)
  78. return
  79. }
  80. func CentralKitchenForSchoolUserList(c *gin.Context) {
  81. var req md.EnterpriseUserListReq
  82. err := c.ShouldBindJSON(&req)
  83. if err != nil {
  84. err = validate.HandleValidateErr(err)
  85. err1 := err.(e.E)
  86. e.OutErr(c, err1.Code, err1.Error())
  87. return
  88. }
  89. resp, err := svc2.EnterpriseUserListByCentralKitchenForSchoolV2(req)
  90. if err != nil {
  91. e.OutErr(c, e.ERR, err.Error())
  92. return
  93. }
  94. e.OutSuc(c, resp, nil)
  95. return
  96. }
  97. func CentralKitchenForSchoolUserUpdate(c *gin.Context) {
  98. var req md.CentralKitchenForSchoolUserUpdateReqV2
  99. err := c.ShouldBindJSON(&req)
  100. if err != nil {
  101. err = validate.HandleValidateErr(err)
  102. err1 := err.(e.E)
  103. e.OutErr(c, err1.Code, err1.Error())
  104. return
  105. }
  106. err = svc2.CentralKitchenForSchoolUserUpdateV2(req)
  107. if err != nil {
  108. e.OutErr(c, e.ERR, err.Error())
  109. return
  110. }
  111. e.OutSuc(c, "success", nil)
  112. return
  113. }
  114. func CentralKitchenForSchoolUserDelete(c *gin.Context) {
  115. var req md.CentralKitchenForSchoolUserDeleteReq
  116. err := c.ShouldBindJSON(&req)
  117. if err != nil {
  118. err = validate.HandleValidateErr(err)
  119. err1 := err.(e.E)
  120. e.OutErr(c, err1.Code, err1.Error())
  121. return
  122. }
  123. err = svc2.CentralKitchenForSchoolUserDeleteV2(req)
  124. if err != nil {
  125. e.OutErr(c, e.ERR, err.Error())
  126. return
  127. }
  128. e.OutSuc(c, "success", nil)
  129. return
  130. }
  131. func UserUpdate(c *gin.Context) {
  132. var req md.UserList
  133. err := c.ShouldBindJSON(&req)
  134. if err != nil {
  135. err = validate.HandleValidateErr(err)
  136. err1 := err.(e.E)
  137. e.OutErr(c, err1.Code, err1.Error())
  138. return
  139. }
  140. err = svc.UserUpdate(req)
  141. if err != nil {
  142. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  143. return
  144. }
  145. e.OutSuc(c, "success", nil)
  146. return
  147. }
  148. func UserDelete(c *gin.Context) {
  149. id := c.Param("id")
  150. //TODO::判断当前用户下是否还绑定了身份
  151. userIdentityDb := db.UserIdentityDb{}
  152. userIdentityDb.Set(utils.StrToInt(id))
  153. identity, err := userIdentityDb.FindUserIdentity()
  154. if err != nil {
  155. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  156. return
  157. }
  158. if len(*identity) > 0 {
  159. e.OutErr(c, e.ERR_DB_ORM, "当前用户下存在未解绑身份")
  160. return
  161. }
  162. userDb := db.UserDb{}
  163. userDb.Set()
  164. _, err = userDb.DeleteUser(utils.StrToInt(id))
  165. if err != nil {
  166. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  167. return
  168. }
  169. e.OutSuc(c, "success", nil)
  170. return
  171. }