面包店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_role_permission_group.go 888 B

9 months ago
12345678910111213141516171819202122232425262728293031
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "reflect"
  5. "xorm.io/xorm"
  6. )
  7. type RolePermissionGroupDb struct {
  8. Db *xorm.Engine `json:"db"`
  9. }
  10. func (rolePermissionGroupDb *RolePermissionGroupDb) Set() { // set方法
  11. rolePermissionGroupDb.Db = Db
  12. }
  13. func (rolePermissionGroupDb *RolePermissionGroupDb) RolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) {
  14. if reflect.TypeOf(roleId).Kind() == reflect.Slice {
  15. return session.In("role_id", roleId).Delete(model.RolePermissionGroup{})
  16. } else {
  17. return session.Where("role_id = ?", roleId).Delete(model.RolePermissionGroup{})
  18. }
  19. }
  20. func (rolePermissionGroupDb *RolePermissionGroupDb) BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) {
  21. affected, err := session.Insert(mm)
  22. if err != nil {
  23. return 0, err
  24. }
  25. return affected, nil
  26. }