apirole

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RoleAnonymous = "anonymous"

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSource

type DataSource interface {
	GetRoleAll() ([]Roles, error)
	GetRoleById(id string) (Roles, error)
	AddRole(data *Roles) error
	UpdateRole(data Roles) error
	DeleteRole(id string) error
	CheckRoleDisplayExist(display string) Roles

	GetRoleUserAll() ([]RoleUser, error)
	GetRoleUserById(id string) (RoleUser, error)
	GetRoleUserByRoleId(id string) (RoleUser, error)
	AddRoleUser(data *RoleUser) error
	UpdateRoleUser(data RoleUser) error
	DeleteRoleUser(id string) error
	RoleUserExist(data RoleUser) bool

	GetPolicyAll() ([]Policy, error)
	GetPolicyById(id string) (Policy, error)
	GetPolicyByRoleId(id string) (Policy, error)
	GetPolicyListByRoleId(id string) ([]Policy, error)
	UpdatePolicy(data Policy) error
	PolicyExist(data Policy) bool
}

DataSource is the interface

func NewDataSource

func NewDataSource(mgoDb *mongo.Database) DataSource

NewDataSource new instance

type Handler

type Handler interface {
	GetRoleByID(c *fiber.Ctx) error
	GetRoleList(c *fiber.Ctx) error
	CreateRole(c *fiber.Ctx) error
	UpdateRole(c *fiber.Ctx) error
	DeleteRole(c *fiber.Ctx) error

	GetRoleUserByID(c *fiber.Ctx) error
	GetRoleUserList(c *fiber.Ctx) error
	CreateRoleUser(c *fiber.Ctx) error
	UpdateRoleUser(c *fiber.Ctx) error
	DeleteRoleUser(c *fiber.Ctx) error

	GetPolicyByID(c *fiber.Ctx) error
	GetPolicyListByRoleId(c *fiber.Ctx) error
	GetPolicyList(c *fiber.Ctx) error
	CreatePolicy(c *fiber.Ctx) error
	UpdatePolicy(c *fiber.Ctx) error
	DeletePolicy(c *fiber.Ctx) error
}

Handler is the interface

func NewHandler

func NewHandler(uc UseCase) Handler

NewHandler new instance

type Policy

type Policy struct {
	ID     primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Policy string             `json:"-" bson:"ptype"`
	RoleId string             `json:"roleId" bson:"v0"`
	Path   string             `json:"path" bson:"v1"`
	Method string             `json:"method" bson:"v2"`
	V3     string             `json:"v3" bson:"v3"`
	V4     string             `json:"v4" bson:"v4"`
	V5     string             `json:"v5" bson:"v5"`
}

Policy a model

type Repository

type Repository interface {
	GetRoleAll() ([]Roles, error)
	GetRoleById(id string) (Roles, error)
	AddRole(data *Roles) error
	UpdateRole(data Roles) error
	DeleteRole(id string) error
	CheckRoleDisplayExist(display string) Roles

	GetRoleUserAll() ([]RoleUser, error)
	GetRoleUserById(id string) (RoleUser, error)
	AddRoleUser(data *RoleUser) error
	UpdateRoleUser(data RoleUser) error
	DeleteRoleUser(id string) error
	RoleUserExist(data RoleUser) bool

	GetPolicyAll() ([]Policy, error)
	GetPolicyById(id string) (Policy, error)
	GetPolicyListByRoleId(id string) ([]Policy, error)
	AddPolicy(data *Policy) error
	UpdatePolicy(data Policy) error
	DeletePolicy(id string) error
	PolicyExist(data Policy) bool
}

Repository is a interface

func NewRepository

func NewRepository(enforcer *casbin.Enforcer, source DataSource) Repository

NewRepository new instance

type RoleUser

type RoleUser struct {
	ID     primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID int                `json:"userId" bson:"userId"`
	RoleID string             `json:"roleId" bson:"roleId"`
}

RoleUser a model

type Roles

type Roles struct {
	ID          primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Display     string             `json:"display"`
	Description string             `json:"description"`
	CreatedAt   time.Time          `json:"createdAt"`
	UpdatedAt   time.Time          `json:"updatedAt"`
}

Roles a model

type Router

type Router interface {
	Initial(e *fiber.App)
}

Router is interface

func NewRouter

func NewRouter(handle Handler) Router

NewRouter new instance

type UseCase

type UseCase interface {
	GetRoleAll() ([]Roles, error)
	GetRoleById(id string) (Roles, error)
	AddRole(data *Roles) error
	UpdateRole(data Roles) error
	DeleteRole(id string) error
	CheckRoleDisplayExist(display string) Roles

	GetRoleUserAll() ([]RoleUser, error)
	GetRoleUserById(id string) (RoleUser, error)
	AddRoleUser(data *RoleUser) error
	UpdateRoleUser(data RoleUser) error
	DeleteRoleUser(id string) error
	RoleUserExist(data RoleUser) bool

	GetPolicyAll() ([]Policy, error)
	GetPolicyById(id string) (Policy, error)
	GetPolicyListByRoleId(id string) ([]Policy, error)
	AddPolicy(data *Policy) error
	UpdatePolicy(data Policy) error
	DeletePolicy(id string) error
	PolicyExist(data Policy) bool
}

UseCase is the interface

func NewUseCase

func NewUseCase(repo Repository) UseCase

NewUseCase new instance

Jump to

Keyboard shortcuts

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