package implement import ( "applet/app/db/dao" "applet/app/db/model" "reflect" "xorm.io/xorm" ) func NewRolePermissionGroupDb(engine *xorm.Engine) dao.RolePermissionGroupDao { return &RolePermissionGroupDb{Db: engine} } type RolePermissionGroupDb struct { Db *xorm.Engine } func (r RolePermissionGroupDb) RolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) { if reflect.TypeOf(roleId).Kind() == reflect.Slice { return session.In("role_id", roleId).Delete(model.RolePermissionGroup{}) } else { return session.Where("role_id = ?", roleId).Delete(model.RolePermissionGroup{}) } } func (r RolePermissionGroupDb) BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) { affected, err := session.Insert(mm) if err != nil { return 0, err } return affected, nil }