在actions中添加权限

This commit is contained in:
linwenxiang
2020-08-30 00:21:03 +08:00
parent 61451d149a
commit abc8b271c4
4 changed files with 78 additions and 3 deletions
+5
View File
@@ -2,6 +2,7 @@ package models
import (
"github.com/pkg/errors"
"gorm.io/gorm"
orm "go-admin/global"
"go-admin/tools"
@@ -33,6 +34,10 @@ type MenuIdList struct {
MenuId int `json:"menuId"`
}
func (role *SysRole) GetById(tx *gorm.DB, id interface{}) error {
return tx.First(role, id).Error
}
func (role *SysRole) GetPage(pageSize int, pageIndex int) ([]SysRole, int, error) {
var doc []SysRole
+6 -1
View File
@@ -2,6 +2,7 @@ package models
import (
"errors"
"gorm.io/gorm"
"log"
"strings"
@@ -224,7 +225,7 @@ func (e *SysUser) GetPage(pageSize int, pageIndex int) ([]SysUserPage, int, erro
var count int64
if err := table.Scopes(DataScopes(e.TableName(),userid)).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
if err := table.Scopes(DataScopes(e.TableName(), userid)).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
return nil, 0, err
}
//table.Where("sys_user.deleted_at IS NULL").Count(&count)
@@ -316,3 +317,7 @@ func (e *SysUser) SetPwd(pwd SysUserPwd) (Result bool, err error) {
tools.HasError(err, "更新密码失败(代码202)", 500)
return
}
func (e *SysUser) GetByUserId(tx *gorm.DB, id interface{}) error {
return tx.First(e, id).Error
}