package implement import ( "applet/app/db/dao" "applet/app/db/model" "reflect" "xorm.io/xorm" ) func NewMediumRolePermissionGroupDb(engine *xorm.Engine) dao.MediumRolePermissionGroupDao { return &MediumRolePermissionGroupDb{Db: engine} } type MediumRolePermissionGroupDb struct { Db *xorm.Engine } func (m MediumRolePermissionGroupDb) MediumRolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { if reflect.TypeOf(roleId).Kind() == reflect.Slice { return session.In("role_id", roleId).Delete(model.MediumRolePermissionGroup{}) } else { return session.Where("role_id = ?", roleId).Delete(model.MediumRolePermissionGroup{}) } } func (m MediumRolePermissionGroupDb) BatchAddMediumRolePermissionGroupBySession(session *xorm.Session, mm []*model.MediumRolePermissionGroup) (int64, error) { affected, err := session.Insert(mm) if err != nil { return 0, err } return affected, nil }