service

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatabaseError = errors.New("db error")

	ErrInternalError = errors.New("internal error")

	ErrNoSuchObject = errors.New("对象不存在")

	ErrPermissionDenied = errors.New("对象不存在或无权查看")

	NoAuthIdentity = AuthIdentity{
		UserId:   -2,
		Username: "noauth",
		DeptId:   -2,
		RoleId:   -2,
		RoleKey:  "noauth",
		RoleName: "noauth",
	}

	WebIdentity = AuthIdentity{
		UserId:   -1,
		Username: "web",
		DeptId:   -1,
		RoleId:   -1,
		RoleKey:  "web",
		RoleName: "web",
	}
)

Functions

func Permission

func Permission(tableName string, p *AuthIdentity) func(db *gorm.DB) *gorm.DB

Permission check permission of data scope

Types

type AuthIdentity

type AuthIdentity struct {
	UserId    int
	Username  string
	DeptId    int
	RoleId    int
	RoleKey   string
	RoleName  string
	DataScope string
}

func GetIdentity

func GetIdentity(c *gin.Context) *AuthIdentity

type Service

type Service struct {
	Orm      *gorm.DB
	Identity *AuthIdentity
}

func (*Service) ConstructFromDB

func (s *Service) ConstructFromDB(db *gorm.DB)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL