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

116 lines
3.2 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/enum"
  6. "errors"
  7. )
  8. func DeleteUserIdentityForCentralKitchenForStudent(userIdentityId int) (err error) {
  9. //1、删除 user_identity(将`state`变成"冻结"状态)
  10. userIdentityDb := db.UserIdentityDb{}
  11. userIdentityDb.Set(0)
  12. identity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  13. if err != nil {
  14. return err
  15. }
  16. identity.State = enum.UserIdentityStateForFreeze
  17. updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state")
  18. if err != nil {
  19. return err
  20. }
  21. if updateAffected <= 0 {
  22. return errors.New("删除用户信息数据失败")
  23. }
  24. //2、删除 class_with_user
  25. _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{})
  26. if err != nil {
  27. return
  28. }
  29. return
  30. }
  31. func DeleteUserIdentityForCentralKitchenForTeacher(userIdentityId int) (err error) {
  32. //1、删除 user_identity(将`state`变成"冻结"状态)
  33. userIdentityDb := db.UserIdentityDb{}
  34. userIdentityDb.Set(0)
  35. identity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  36. if err != nil {
  37. return err
  38. }
  39. identity.State = enum.UserIdentityStateForFreeze
  40. updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state")
  41. if err != nil {
  42. return err
  43. }
  44. if updateAffected <= 0 {
  45. return errors.New("删除用户信息数据失败")
  46. }
  47. return
  48. }
  49. func DeleteUserIdentityForSelfSupportForStudent(userIdentityId int) (err error) {
  50. //1、删除 user_identity(将`state`变成"冻结"状态)
  51. userIdentityDb := db.UserIdentityDb{}
  52. userIdentityDb.Set(0)
  53. identity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  54. if err != nil {
  55. return err
  56. }
  57. identity.State = enum.UserIdentityStateForFreeze
  58. updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state")
  59. if err != nil {
  60. return err
  61. }
  62. if updateAffected <= 0 {
  63. return errors.New("删除用户信息数据失败")
  64. }
  65. //2、删除 class_with_user
  66. _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{})
  67. if err != nil {
  68. return
  69. }
  70. return
  71. }
  72. func DeleteUserIdentityForSelfSupportForTeacher(userIdentityId int) (err error) {
  73. //1、删除 user_identity(将`state`变成"冻结"状态)
  74. userIdentityDb := db.UserIdentityDb{}
  75. userIdentityDb.Set(0)
  76. identity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  77. if err != nil {
  78. return err
  79. }
  80. identity.State = enum.UserIdentityStateForFreeze
  81. updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state")
  82. if err != nil {
  83. return err
  84. }
  85. if updateAffected <= 0 {
  86. return errors.New("删除用户信息数据失败")
  87. }
  88. return
  89. }
  90. func DeleteUserIdentityForSelfSupportForWorker(userIdentityId int) (err error) {
  91. //1、删除 user_identity(将`state`变成"冻结"状态)
  92. userIdentityDb := db.UserIdentityDb{}
  93. userIdentityDb.Set(0)
  94. identity, err := userIdentityDb.GetUserIdentity(userIdentityId)
  95. if err != nil {
  96. return err
  97. }
  98. identity.State = enum.UserIdentityStateForFreeze
  99. updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state")
  100. if err != nil {
  101. return err
  102. }
  103. if updateAffected <= 0 {
  104. return errors.New("删除用户信息数据失败")
  105. }
  106. return
  107. }