智慧食堂
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_identity.go 17 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. package hdl
  2. import (
  3. "applet/app/customer/lib/validate"
  4. "applet/app/customer/md"
  5. "applet/app/customer/svc"
  6. "applet/app/db"
  7. "applet/app/db/model"
  8. "applet/app/e"
  9. "applet/app/enum"
  10. "applet/app/utils"
  11. "github.com/gin-gonic/gin"
  12. "time"
  13. )
  14. func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) {
  15. var req md.SaveCentralKitchenForSchoolUserIdentityReq
  16. err := c.ShouldBindJSON(&req)
  17. if err != nil {
  18. err = validate.HandleValidateErr(err)
  19. err1 := err.(e.E)
  20. e.OutErr(c, err1.Code, err1.Error())
  21. return
  22. }
  23. user := svc.GetUser(c)
  24. var identity = enum.UserIdentityForCentralKitchenForStudent
  25. if req.IsTeacher {
  26. identity = enum.UserIdentityForCentralKitchenForTeacher
  27. }
  28. //1、判断当前身份是否已绑定
  29. userIdentityDb := db.UserIdentityDb{}
  30. userIdentityDb.Set(user.Id)
  31. isHasUserIdentity, err := userIdentityDb.UserIdentityExistV1(req.EnterpriseId, req.Name)
  32. if err != nil {
  33. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  34. return
  35. }
  36. now := time.Now()
  37. if isHasUserIdentity == nil {
  38. //2、新增身份信息
  39. userIdentity := &model.UserIdentity{
  40. Uid: user.Id,
  41. Name: req.Name,
  42. IdNo: req.IdNo,
  43. CertType: enum.UserIdentityCertTypeForIdCard,
  44. Kind: enum.UserIdentityKindForCommon,
  45. Identity: identity,
  46. EnterpriseId: req.EnterpriseId,
  47. State: enum.UserIdentityStateForNormal,
  48. Memo: "",
  49. CreateAt: now.Format("2006-01-02 15:04:05"),
  50. UpdateAt: now.Format("2006-01-02 15:04:05"),
  51. }
  52. insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity)
  53. if err != nil {
  54. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  55. return
  56. }
  57. if insertAffected <= 0 {
  58. e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败")
  59. return
  60. }
  61. //3、新增 class_with_user 记录
  62. if !req.IsTeacher {
  63. classWithUserDb := db.ClassWithUserDb{}
  64. classWithUserDb.Set()
  65. _, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  66. UserIdentityId: insertAffected,
  67. ClassId: req.ClassId,
  68. CreateAt: now.Format("2006-01-02 15:04:05"),
  69. UpdateAt: now.Format("2006-01-02 15:04:05"),
  70. })
  71. if err != nil {
  72. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  73. return
  74. }
  75. }
  76. } else {
  77. //4、修改身份信息
  78. isHasUserIdentity.Uid = user.Id
  79. isHasUserIdentity.Name = req.Name
  80. isHasUserIdentity.State = enum.UserIdentityStateForNormal
  81. _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state")
  82. if err != nil {
  83. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  84. return
  85. }
  86. //5、修改 class_with_user 记录
  87. if !req.IsTeacher {
  88. classWithUserDb := db.ClassWithUserDb{}
  89. classWithUserDb.Set()
  90. classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(isHasUserIdentity.Id)
  91. if err1 != nil {
  92. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  93. return
  94. }
  95. if classWithUser == nil {
  96. _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  97. UserIdentityId: isHasUserIdentity.Id,
  98. ClassId: req.ClassId,
  99. CreateAt: now.Format("2006-01-02 15:04:05"),
  100. UpdateAt: now.Format("2006-01-02 15:04:05"),
  101. })
  102. if err2 != nil {
  103. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  104. return
  105. }
  106. } else {
  107. classWithUser.ClassId = req.ClassId
  108. _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(isHasUserIdentity.Id, classWithUser, "class_id")
  109. if err2 != nil {
  110. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  111. return
  112. }
  113. }
  114. }
  115. }
  116. e.OutSuc(c, "success", nil)
  117. return
  118. }
  119. func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) {
  120. var req md.SaveSelfSupportForSchoolUserIdentityReq
  121. err := c.ShouldBindJSON(&req)
  122. if err != nil {
  123. err = validate.HandleValidateErr(err)
  124. err1 := err.(e.E)
  125. e.OutErr(c, err1.Code, err1.Error())
  126. return
  127. }
  128. user := svc.GetUser(c)
  129. now := time.Now()
  130. var identity = enum.UserIdentityForSelfSupportForStudent
  131. var kind = enum.UserIdentityKindForCommon
  132. if req.CertType == 0 {
  133. req.CertType = enum.UserIdentityCertTypeForIdCard
  134. }
  135. if req.Kind == enum.UserIdentityKindForWorker {
  136. kind = enum.UserIdentityKindForWorker
  137. identity = enum.UserIdentityForSelfSupportForWorker
  138. req.CertType = enum.UserIdentityCertTypeForIdCard
  139. } else {
  140. if req.IsTeacher {
  141. identity = enum.UserIdentityForCentralKitchenForTeacher
  142. }
  143. }
  144. //1、判断当前身份是否已绑定
  145. userIdentityDb := db.UserIdentityDb{}
  146. userIdentityDb.Set(user.Id)
  147. isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo, req.CertType)
  148. if err != nil {
  149. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  150. return
  151. }
  152. if isHasUserIdentity == nil {
  153. if identity != enum.UserIdentityForSelfSupportForStudent {
  154. e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
  155. return
  156. }
  157. //2、新增身份信息
  158. userIdentity := &model.UserIdentity{
  159. Uid: user.Id,
  160. Name: req.Name,
  161. IdNo: req.IdNo,
  162. CertType: req.CertType,
  163. Kind: kind,
  164. Identity: identity,
  165. EnterpriseId: req.EnterpriseId,
  166. State: enum.UserIdentityStateForNormal,
  167. Memo: "",
  168. CreateAt: now.Format("2006-01-02 15:04:05"),
  169. UpdateAt: now.Format("2006-01-02 15:04:05"),
  170. }
  171. insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity)
  172. if err != nil {
  173. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  174. return
  175. }
  176. if insertAffected <= 0 {
  177. e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败")
  178. return
  179. }
  180. //3、新增 class_with_user 记录
  181. if !req.IsTeacher {
  182. classWithUserDb := db.ClassWithUserDb{}
  183. classWithUserDb.Set()
  184. _, err1 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  185. UserIdentityId: insertAffected,
  186. ClassId: req.ClassId,
  187. CreateAt: now.Format("2006-01-02 15:04:05"),
  188. UpdateAt: now.Format("2006-01-02 15:04:05"),
  189. })
  190. if err1 != nil {
  191. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  192. return
  193. }
  194. }
  195. //4、新增 self_support_for_user_face_info 记录
  196. selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{}
  197. selfSupportForSchoolInfoDb.Set(req.EnterpriseId)
  198. selfSupportForSchoolInfo, err := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo()
  199. if err != nil {
  200. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  201. return
  202. }
  203. if selfSupportForSchoolInfo == nil {
  204. e.OutErr(c, e.ERR_NO_DATA, "当前学校暂未完成《一脸通行入驻》")
  205. return
  206. }
  207. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  208. selfSupportForUserFaceInfoDb.Set(insertAffected)
  209. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(&model.SelfSupportForUserFaceInfo{
  210. EnterpriseId: req.EnterpriseId,
  211. UserIdentityId: insertAffected,
  212. CollectFaceType: 1,
  213. SchoolCode: selfSupportForSchoolInfo.SchoolCode,
  214. SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode,
  215. ParentUserId: "",
  216. ParentLogonId: "",
  217. UserId: "",
  218. SchoolFacePassStatus: "CLOSE",
  219. SchoolFacePaymentStatus: "CLOSE",
  220. ConcentrateSchoolFacePassStatus: 1,
  221. CreateAt: now.Format("2006-01-02 15:04:05"),
  222. UpdateAt: now.Format("2006-01-02 15:04:05"),
  223. })
  224. if err2 != nil {
  225. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  226. return
  227. }
  228. } else {
  229. if isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id {
  230. e.OutErr(c, e.ERR, "当前身份信息已被绑定使用")
  231. return
  232. }
  233. //4、修改身份信息
  234. isHasUserIdentity.Uid = user.Id
  235. isHasUserIdentity.Name = req.Name
  236. isHasUserIdentity.State = enum.UserIdentityStateForNormal
  237. _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state")
  238. if err != nil {
  239. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  240. return
  241. }
  242. if identity == enum.UserIdentityForSelfSupportForStudent {
  243. //5、修改 class_with_user 记录
  244. classWithUserDb := db.ClassWithUserDb{}
  245. classWithUserDb.Set()
  246. classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(isHasUserIdentity.Id)
  247. if err1 != nil {
  248. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  249. return
  250. }
  251. if classWithUser == nil {
  252. _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  253. UserIdentityId: isHasUserIdentity.Id,
  254. ClassId: req.ClassId,
  255. CreateAt: now.Format("2006-01-02 15:04:05"),
  256. UpdateAt: now.Format("2006-01-02 15:04:05"),
  257. })
  258. if err2 != nil {
  259. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  260. return
  261. }
  262. } else {
  263. classWithUser.ClassId = req.ClassId
  264. _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(isHasUserIdentity.Id, classWithUser, "class_id")
  265. if err2 != nil {
  266. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  267. return
  268. }
  269. }
  270. }
  271. }
  272. e.OutSuc(c, "success", nil)
  273. return
  274. }
  275. func SaveNursingHomeUserIdentity(c *gin.Context) {
  276. var req md.SaveNursingHomeUserIdentityReq
  277. err := c.ShouldBindJSON(&req)
  278. if err != nil {
  279. err = validate.HandleValidateErr(err)
  280. err1 := err.(e.E)
  281. e.OutErr(c, err1.Code, err1.Error())
  282. return
  283. }
  284. user := svc.GetUser(c)
  285. var identity = enum.UserIdentityForNursingHome
  286. //1、判断当前身份是否已绑定
  287. userIdentityDb := db.UserIdentityDb{}
  288. userIdentityDb.Set(user.Id)
  289. isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo, enum.UserIdentityCertTypeForIdCard)
  290. if err != nil {
  291. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  292. return
  293. }
  294. now := time.Now()
  295. if isHasUserIdentity == nil {
  296. //2、新增身份信息
  297. userIdentity := &model.UserIdentity{
  298. Uid: user.Id,
  299. Name: req.Name,
  300. IdNo: req.IdNo,
  301. Kind: enum.UserIdentityKindForCommon,
  302. Identity: identity,
  303. EnterpriseId: req.EnterpriseId,
  304. State: enum.UserIdentityStateForNormal,
  305. Memo: "",
  306. CreateAt: now.Format("2006-01-02 15:04:05"),
  307. UpdateAt: now.Format("2006-01-02 15:04:05"),
  308. }
  309. insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity)
  310. if err != nil {
  311. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  312. return
  313. }
  314. if insertAffected <= 0 {
  315. e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败")
  316. return
  317. }
  318. } else {
  319. //4、修改身份信息
  320. isHasUserIdentity.Uid = user.Id
  321. isHasUserIdentity.Name = req.Name
  322. isHasUserIdentity.State = enum.UserIdentityStateForNormal
  323. _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state")
  324. if err != nil {
  325. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  326. return
  327. }
  328. }
  329. e.OutSuc(c, "success", nil)
  330. return
  331. }
  332. func UpdateCentralKitchenForSchoolUserIdentity(c *gin.Context) {
  333. var req md.UpdateCentralKitchenForSchoolUserIdentityReq
  334. err := c.ShouldBindJSON(&req)
  335. if err != nil {
  336. err = validate.HandleValidateErr(err)
  337. err1 := err.(e.E)
  338. e.OutErr(c, err1.Code, err1.Error())
  339. return
  340. }
  341. user := svc.GetUser(c)
  342. now := time.Now()
  343. //1、查询当前身份是否存在
  344. userIdentityDb := db.UserIdentityDb{}
  345. userIdentityDb.Set(user.Id)
  346. userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId)
  347. if err != nil {
  348. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  349. return
  350. }
  351. if userIdentity == nil {
  352. e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
  353. return
  354. }
  355. //2、修改身份信息
  356. userIdentity.Name = req.Name
  357. userIdentity.IdNo = req.IdNo
  358. _, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name")
  359. if err != nil {
  360. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  361. return
  362. }
  363. //3、修改 class_with_user 记录
  364. if userIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent {
  365. classWithUserDb := db.ClassWithUserDb{}
  366. classWithUserDb.Set()
  367. classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(userIdentity.Id)
  368. if err1 != nil {
  369. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  370. return
  371. }
  372. if classWithUser == nil {
  373. _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  374. UserIdentityId: userIdentity.Id,
  375. ClassId: req.ClassId,
  376. CreateAt: now.Format("2006-01-02 15:04:05"),
  377. UpdateAt: now.Format("2006-01-02 15:04:05"),
  378. })
  379. if err2 != nil {
  380. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  381. return
  382. }
  383. } else {
  384. classWithUser.ClassId = req.ClassId
  385. _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(userIdentity.Id, classWithUser, "class_id")
  386. if err2 != nil {
  387. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  388. return
  389. }
  390. }
  391. }
  392. e.OutSuc(c, "success", nil)
  393. return
  394. }
  395. func UpdateSelfSupportForSchoolUserIdentity(c *gin.Context) {
  396. var req md.UpdateSelfSupportForSchoolUserIdentityReq
  397. err := c.ShouldBindJSON(&req)
  398. if err != nil {
  399. err = validate.HandleValidateErr(err)
  400. err1 := err.(e.E)
  401. e.OutErr(c, err1.Code, err1.Error())
  402. return
  403. }
  404. user := svc.GetUser(c)
  405. now := time.Now()
  406. //1、查询当前身份是否存在
  407. userIdentityDb := db.UserIdentityDb{}
  408. userIdentityDb.Set(user.Id)
  409. userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId)
  410. if err != nil {
  411. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  412. return
  413. }
  414. if userIdentity == nil {
  415. e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
  416. return
  417. }
  418. //2、修改身份信息
  419. userIdentity.Name = req.Name
  420. userIdentity.IdNo = req.IdNo
  421. _, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name")
  422. if err != nil {
  423. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  424. return
  425. }
  426. //3、修改 class_with_user 记录
  427. if userIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
  428. classWithUserDb := db.ClassWithUserDb{}
  429. classWithUserDb.Set()
  430. classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(userIdentity.Id)
  431. if err1 != nil {
  432. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  433. return
  434. }
  435. if classWithUser == nil {
  436. _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
  437. UserIdentityId: userIdentity.Id,
  438. ClassId: req.ClassId,
  439. CreateAt: now.Format("2006-01-02 15:04:05"),
  440. UpdateAt: now.Format("2006-01-02 15:04:05"),
  441. })
  442. if err2 != nil {
  443. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  444. return
  445. }
  446. } else {
  447. classWithUser.ClassId = req.ClassId
  448. _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(userIdentity.Id, classWithUser, "class_id")
  449. if err2 != nil {
  450. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  451. return
  452. }
  453. }
  454. }
  455. e.OutSuc(c, "success", nil)
  456. return
  457. }
  458. func UpdateNursingHomeUserIdentity(c *gin.Context) {
  459. var req md.UpdateNursingHomeUserIdentityReq
  460. err := c.ShouldBindJSON(&req)
  461. if err != nil {
  462. err = validate.HandleValidateErr(err)
  463. err1 := err.(e.E)
  464. e.OutErr(c, err1.Code, err1.Error())
  465. return
  466. }
  467. user := svc.GetUser(c)
  468. //1、查询当前身份是否存在
  469. userIdentityDb := db.UserIdentityDb{}
  470. userIdentityDb.Set(user.Id)
  471. userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId)
  472. if err != nil {
  473. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  474. return
  475. }
  476. if userIdentity == nil {
  477. e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
  478. return
  479. }
  480. //2、修改身份信息
  481. userIdentity.Name = req.Name
  482. userIdentity.IdNo = req.IdNo
  483. _, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name")
  484. if err != nil {
  485. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  486. return
  487. }
  488. e.OutSuc(c, "success", nil)
  489. return
  490. }
  491. func DeleteUserIdentity(c *gin.Context) {
  492. userIdentityId := utils.StrToInt(c.Param("id"))
  493. user := svc.GetUser(c)
  494. //1、查询当前身份是否存在
  495. userIdentityDb := db.UserIdentityDb{}
  496. userIdentityDb.Set(user.Id)
  497. userIdentity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  498. if err != nil {
  499. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  500. return
  501. }
  502. if userIdentity == nil {
  503. e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
  504. return
  505. }
  506. switch userIdentity.Identity {
  507. case enum.UserIdentityForCentralKitchenForStudent:
  508. err1 := svc.DeleteUserIdentityForCentralKitchenForStudent(userIdentity.Id)
  509. if err1 != nil {
  510. e.OutErr(c, e.ERR, err1.Error())
  511. return
  512. }
  513. break
  514. case enum.UserIdentityForCentralKitchenForTeacher:
  515. err1 := svc.DeleteUserIdentityForCentralKitchenForTeacher(userIdentity.Id)
  516. if err1 != nil {
  517. e.OutErr(c, e.ERR, err1.Error())
  518. return
  519. }
  520. break
  521. case enum.UserIdentityForCentralKitchenForWorker:
  522. break
  523. case enum.UserIdentityForSelfSupportForStudent:
  524. err1 := svc.DeleteUserIdentityForSelfSupportForStudent(userIdentity.Id)
  525. if err1 != nil {
  526. e.OutErr(c, e.ERR, err1.Error())
  527. return
  528. }
  529. break
  530. case enum.UserIdentityForSelfSupportForTeacher:
  531. err1 := svc.DeleteUserIdentityForSelfSupportForTeacher(userIdentity.Id)
  532. if err1 != nil {
  533. e.OutErr(c, e.ERR, err1.Error())
  534. return
  535. }
  536. break
  537. case enum.UserIdentityForSelfSupportForWorker:
  538. err1 := svc.DeleteUserIdentityForSelfSupportForWorker(userIdentity.Id)
  539. if err1 != nil {
  540. e.OutErr(c, e.ERR, err1.Error())
  541. return
  542. }
  543. break
  544. case enum.UserIdentityForNursingHome:
  545. err1 := svc.DeleteUserIdentityForNursingHome(userIdentity.Id)
  546. if err1 != nil {
  547. e.OutErr(c, e.ERR, err1.Error())
  548. return
  549. }
  550. break
  551. }
  552. e.OutSuc(c, "success", nil)
  553. return
  554. }