智慧食堂
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

hdl_user_identity.go 17 KiB

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