mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-10-03 13:59:52 +00:00
在actions中添加权限
This commit is contained in:
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user