package svc import ( db "code.fnuoos.com/zhimeng/model.git/src" "code.fnuoos.com/zhimeng/model.git/src/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.NewAgentDb(engine) _, err = adminDb.AgentDeleteBySession(session, admIds) if err != nil { _ = session.Rollback() return } //2、删除 `admin_role` adminRoleDb := implement.NewAgentWithRoleDb(engine) _, err = adminRoleDb.AgentDeleteBySessionForAdmId(session, admIds) if err != nil { _ = session.Rollback() return } return session.Commit() }