广告平台(总站长使用)
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.

role_permission_group_implement.go 884 B

4 kuukautta sitten
1234567891011121314151617181920212223242526272829303132
  1. package implement
  2. import (
  3. "applet/app/db/dao"
  4. "applet/app/db/model"
  5. "reflect"
  6. "xorm.io/xorm"
  7. )
  8. func NewRolePermissionGroupDb(engine *xorm.Engine) dao.RolePermissionGroupDao {
  9. return &RolePermissionGroupDb{Db: engine}
  10. }
  11. type RolePermissionGroupDb struct {
  12. Db *xorm.Engine
  13. }
  14. func (r RolePermissionGroupDb) RolePermissionGroupDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) {
  15. if reflect.TypeOf(roleId).Kind() == reflect.Slice {
  16. return session.In("role_id", roleId).Delete(model.RolePermissionGroup{})
  17. } else {
  18. return session.Where("role_id = ?", roleId).Delete(model.RolePermissionGroup{})
  19. }
  20. }
  21. func (r RolePermissionGroupDb) BatchAddRolePermissionGroupBySession(session *xorm.Session, mm []*model.RolePermissionGroup) (int64, error) {
  22. affected, err := session.Insert(mm)
  23. if err != nil {
  24. return 0, err
  25. }
  26. return affected, nil
  27. }