智慧食堂
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
560 B

  1. package svc
  2. import (
  3. "applet/app/db"
  4. )
  5. func AdminDelete(admIds []int) (err error) {
  6. session := db.Db.NewSession()
  7. defer session.Close()
  8. session.Begin()
  9. //1、删除 `admin`
  10. adminDb := db.AdminDb{}
  11. adminDb.Set()
  12. _, err = adminDb.AdminDeleteBySession(session, admIds)
  13. if err != nil {
  14. _ = session.Rollback()
  15. return
  16. }
  17. //2、删除 `admin_role`
  18. adminRoleDb := db.AdminRoleDb{}
  19. adminRoleDb.Set()
  20. _, err = adminRoleDb.AdminDeleteBySessionForAdmId(session, admIds)
  21. if err != nil {
  22. _ = session.Rollback()
  23. return
  24. }
  25. return session.Commit()
  26. }