package implement import ( "applet/app/db/dao" "applet/app/db/model" "reflect" "xorm.io/xorm" ) func NewAgentRolePermissionGroupDb(engine *xorm.Engine) dao.AgentRolePermissionGroupDao { return &AgentRolePermissionGroupDb{Db: engine} } type AgentRolePermissionGroupDb struct { Db *xorm.Engine } func (a AgentRolePermissionGroupDb) AgentRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { if reflect.TypeOf(roleId).Kind() == reflect.Slice { return session.In("role_id", roleId).Delete(model.AgentRolePermissionGroup{}) } else { return session.Where("role_id = ?", roleId).Delete(model.AgentRolePermissionGroup{}) } } func (a AgentRolePermissionGroupDb) BatchAddAgentRolePermissionGroupBySession(session *xorm.Session, mm []*model.AgentRolePermissionGroup) (int64, error) { affected, err := session.Insert(mm) if err != nil { return 0, err } return affected, nil }