package db import ( "applet/app/db/model" "reflect" "xorm.io/xorm" ) type RolePermissionGroupDb struct { Db *xorm.Engine `json:"db"` } func (rolePermissionGroupDb *RolePermissionGroupDb) Set() { // set方法 rolePermissionGroupDb.Db = Db } func (rolePermissionGroupDb *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 (rolePermissionGroupDb *RolePermissionGroupDb) BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) { affected, err := session.Insert(mm) if err != nil { return 0, err } return affected, nil }