智慧食堂
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

hdl_user.go 5.0 KiB

1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
  58. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  59. },
  60. {
  61. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
  62. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  63. },
  64. {
  65. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
  66. "value": enum.EnterpriseKindBySelfSupportForSchool,
  67. },
  68. {
  69. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
  70. "value": enum.EnterpriseKindBySelfSupportForFactory,
  71. },
  72. {
  73. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
  74. "value": enum.EnterpriseKindByNursingHome,
  75. },
  76. },
  77. "user_identity_cert_type_list": []map[string]interface{}{
  78. {
  79. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForIdCard),
  80. "value": enum.UserIdentityCertTypeForIdCard,
  81. },
  82. {
  83. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForStudentId),
  84. "value": enum.UserIdentityCertTypeForStudentId,
  85. },
  86. //{
  87. // "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport),
  88. // "value": enum.UserIdentityCertTypeForPassport,
  89. //},
  90. },
  91. }, nil)
  92. return
  93. }
  94. func CentralKitchenForSchoolUserList(c *gin.Context) {
  95. var req md.EnterpriseUserListReq
  96. err := c.ShouldBindJSON(&req)
  97. if err != nil {
  98. err = validate.HandleValidateErr(err)
  99. err1 := err.(e.E)
  100. e.OutErr(c, err1.Code, err1.Error())
  101. return
  102. }
  103. resp, err := svc2.EnterpriseUserListByCentralKitchenForSchoolV2(req)
  104. if err != nil {
  105. e.OutErr(c, e.ERR, err.Error())
  106. return
  107. }
  108. e.OutSuc(c, resp, nil)
  109. return
  110. }
  111. func CentralKitchenForSchoolUserUpdate(c *gin.Context) {
  112. var req md.CentralKitchenForSchoolUserUpdateReqV2
  113. err := c.ShouldBindJSON(&req)
  114. if err != nil {
  115. err = validate.HandleValidateErr(err)
  116. err1 := err.(e.E)
  117. e.OutErr(c, err1.Code, err1.Error())
  118. return
  119. }
  120. err = svc2.CentralKitchenForSchoolUserUpdateV2(req)
  121. if err != nil {
  122. e.OutErr(c, e.ERR, err.Error())
  123. return
  124. }
  125. e.OutSuc(c, "success", nil)
  126. return
  127. }
  128. func CentralKitchenForSchoolUserDelete(c *gin.Context) {
  129. var req md.CentralKitchenForSchoolUserDeleteReq
  130. err := c.ShouldBindJSON(&req)
  131. if err != nil {
  132. err = validate.HandleValidateErr(err)
  133. err1 := err.(e.E)
  134. e.OutErr(c, err1.Code, err1.Error())
  135. return
  136. }
  137. err = svc2.CentralKitchenForSchoolUserDeleteV2(req)
  138. if err != nil {
  139. e.OutErr(c, e.ERR, err.Error())
  140. return
  141. }
  142. e.OutSuc(c, "success", nil)
  143. return
  144. }
  145. func UserUpdate(c *gin.Context) {
  146. var req md.UserList
  147. err := c.ShouldBindJSON(&req)
  148. if err != nil {
  149. err = validate.HandleValidateErr(err)
  150. err1 := err.(e.E)
  151. e.OutErr(c, err1.Code, err1.Error())
  152. return
  153. }
  154. err = svc.UserUpdate(req)
  155. if err != nil {
  156. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  157. return
  158. }
  159. e.OutSuc(c, "success", nil)
  160. return
  161. }
  162. func UserDelete(c *gin.Context) {
  163. id := c.Param("id")
  164. //TODO::判断当前用户下是否还绑定了身份
  165. userIdentityDb := db.UserIdentityDb{}
  166. userIdentityDb.Set(utils.StrToInt(id))
  167. identity, err := userIdentityDb.FindUserIdentity()
  168. if err != nil {
  169. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  170. return
  171. }
  172. if len(*identity) > 0 {
  173. e.OutErr(c, e.ERR_DB_ORM, "当前用户下存在未解绑身份")
  174. return
  175. }
  176. userDb := db.UserDb{}
  177. userDb.Set()
  178. _, err = userDb.DeleteUser(utils.StrToInt(id))
  179. if err != nil {
  180. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  181. return
  182. }
  183. e.OutSuc(c, "success", nil)
  184. return
  185. }