package svc import ( "applet/app/db" "applet/app/db/implement" "github.com/gin-gonic/gin" ) func AdminDelete(c *gin.Context, admIds []int) (err error) { engine := db.DBs[GetMasterId(c)] session := engine.NewSession() defer session.Close() session.Begin() //1、删除 `admin` adminDb := implement.NewAdminDb(engine) _, err = adminDb.AdminDeleteBySession(session, admIds) if err != nil { _ = session.Rollback() return } //2、删除 `admin_role` adminRoleDb := implement.NewAdminRoleDb(engine) _, err = adminRoleDb.AdminDeleteBySessionForAdmId(session, admIds) if err != nil { _ = session.Rollback() return } return session.Commit() }