services

package
v0.0.0-...-9ad592c Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module exports services present

Functions

This section is empty.

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(redis lib.Redis, config lib.Config) AuthService

func (AuthService) DestroyToken

func (a AuthService) DestroyToken(username string) error

func (AuthService) GenerateToken

func (a AuthService) GenerateToken(user *models.User) (string, error)

func (AuthService) ParseToken

func (a AuthService) ParseToken(tokenString string) (*dto.JwtClaims, error)

type CasbinAdapter

type CasbinAdapter struct {
	// contains filtered or unexported fields
}

func (CasbinAdapter) AddPolicy

func (a CasbinAdapter) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.

func (CasbinAdapter) LoadPolicy

func (a CasbinAdapter) LoadPolicy(model casbinModel.Model) error

LoadPolicy loads all policy rules from the storage.

func (CasbinAdapter) RemoveFilteredPolicy

func (a CasbinAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.

func (CasbinAdapter) RemovePolicy

func (a CasbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.

func (CasbinAdapter) SavePolicy

func (a CasbinAdapter) SavePolicy(model casbinModel.Model) error

SavePolicy saves all policy rules to the storage.

type CasbinLogger

type CasbinLogger struct {
	// contains filtered or unexported fields
}

func (*CasbinLogger) EnableLog

func (a *CasbinLogger) EnableLog(enable bool)

func (*CasbinLogger) IsEnabled

func (a *CasbinLogger) IsEnabled() bool

func (*CasbinLogger) LogEnforce

func (a *CasbinLogger) LogEnforce(matcher string, request []interface{}, result bool, explains [][]string)

func (*CasbinLogger) LogModel

func (a *CasbinLogger) LogModel(model [][]string)

func (*CasbinLogger) LogPolicy

func (a *CasbinLogger) LogPolicy(policy map[string][][]string)

func (*CasbinLogger) LogRole

func (a *CasbinLogger) LogRole(roles []string)

type CasbinService

type CasbinService struct {
	Enforcer *casbin.SyncedEnforcer
}

CasbinService service layer

func NewCasbinService

func NewCasbinService(
	logger lib.Logger,
	config lib.Config,

	userRepository repository.UserRepository,
	userRoleRepository repository.UserRoleRepository,
	roleRepository repository.RoleRepository,
	roleMenuRepository repository.RoleMenuRepository,
	menuActionResourceRepository repository.MenuActionResourceRepository,
) CasbinService

NewCasbinService creates a new userservice

type MenuService struct {
	// contains filtered or unexported fields
}

MenuService service layer

func NewMenuService

func NewMenuService(
	logger lib.Logger,
	menuRepository repository.MenuRepository,
	menuActionRepository repository.MenuActionRepository,
	menuActionResourceRepository repository.MenuActionResourceRepository,
) MenuService

NewMenuService creates a new menu service

func (a MenuService) Check(item *models.Menu) error
func (a MenuService) CompareActions(oActions, nActions models.MenuActions) (aList, dList, uList models.MenuActions)
func (a MenuService) CompareResources(oResources, nResources models.MenuActionResources) (aList, dList models.MenuActionResources)
func (a MenuService) Create(menu *models.Menu) (id string, err error)
func (a MenuService) CreateActions(menuID string, menuActions models.MenuActions) error
func (a MenuService) CreateMenus(parentID string, mTrees models.MenuTrees) error
func (a MenuService) Delete(id string) error
func (a MenuService) Get(id string) (*models.Menu, error)
func (a MenuService) GetMenuActions(id string) (models.MenuActions, error)
func (a MenuService) GetParentPath(parentID string) (string, error)
func (a MenuService) JoinParentPath(parent, id string) string
func (a MenuService) Update(id string, menu *models.Menu) error
func (a MenuService) UpdateActions(menuID string, actions models.MenuActions) error
func (a MenuService) UpdateChildParentPath(oMenu, nMenu *models.Menu) error
func (a MenuService) UpdateStatus(id string, status int) error
func (a MenuService) WithTrx(trxHandle *gorm.DB) MenuService

WithTrx delegates transaction to repository database

type RoleService

type RoleService struct {
	// contains filtered or unexported fields
}

RoleService service layer

func NewRoleService

func NewRoleService(
	logger lib.Logger,
	casbinService CasbinService,
	userRepository repository.UserRepository,
	roleRepository repository.RoleRepository,
	roleMenuRepository repository.RoleMenuRepository,
	menuRepository repository.MenuRepository,
	menuActionRepository repository.MenuActionRepository,
) RoleService

NewRoleService creates a new roleservice

func (RoleService) Check

func (a RoleService) Check(item *models.Role) error

func (RoleService) CheckRoleMenu

func (a RoleService) CheckRoleMenu(rMenu *models.RoleMenu) error

func (RoleService) CompareRoleMenus

func (a RoleService) CompareRoleMenus(oRoleMenus, nRoleMenus models.RoleMenus) (aList, dList models.RoleMenus)

func (RoleService) Create

func (a RoleService) Create(role *models.Role) (id string, err error)

func (RoleService) Delete

func (a RoleService) Delete(id string) error

func (RoleService) Get

func (a RoleService) Get(id string) (*models.Role, error)

func (RoleService) Query

func (a RoleService) Query(param *models.RoleQueryParam) (roleQR *models.RoleQueryResult, err error)

func (RoleService) QueryRoleMenus

func (a RoleService) QueryRoleMenus(roleID string) (models.RoleMenus, error)

func (RoleService) Update

func (a RoleService) Update(id string, role *models.Role) error

func (RoleService) UpdateStatus

func (a RoleService) UpdateStatus(id string, status int) error

func (RoleService) WithTrx

func (a RoleService) WithTrx(trxHandle *gorm.DB) RoleService

WithTrx delegates transaction to repository database

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService service layer

func NewUserService

func NewUserService(
	logger lib.Logger,
	userRepository repository.UserRepository,
	userRoleRepository repository.UserRoleRepository,
	roleRepository repository.RoleRepository,
	roleMenuRepository repository.RoleMenuRepository,
	menuRepository repository.MenuRepository,
	menuActionRepository repository.MenuActionRepository,
	casbinService CasbinService,
	config lib.Config,
) UserService

NewUserService creates a new userservice

func (UserService) Check

func (a UserService) Check(user *models.User) error

func (UserService) CompareUserRoles

func (a UserService) CompareUserRoles(oUserRoles, nUserRoles models.UserRoles) (aList, dList models.UserRoles)

func (UserService) Create

func (a UserService) Create(user *models.User) (id string, err error)

func (UserService) Delete

func (a UserService) Delete(id string) error

func (UserService) Get

func (a UserService) Get(id string) (*models.User, error)

func (UserService) GetByUsername

func (a UserService) GetByUsername(username string) (*models.User, error)

func (UserService) GetSuperAdmin

func (a UserService) GetSuperAdmin() *models.User

func (UserService) GetUserInfo

func (a UserService) GetUserInfo(ID string) (*models.UserInfo, error)

func (UserService) GetUserMenuTrees

func (a UserService) GetUserMenuTrees(ID string) (models.MenuTrees, error)

func (UserService) Query

func (a UserService) Query(param *models.UserQueryParam) (userQR *models.UserQueryResult, err error)

func (UserService) Update

func (a UserService) Update(id string, user *models.User) error

func (UserService) UpdateStatus

func (a UserService) UpdateStatus(id string, status int) error

func (UserService) Verify

func (a UserService) Verify(username, password string) (*models.User, error)

func (UserService) WithTrx

func (a UserService) WithTrx(trxHandle *gorm.DB) UserService

WithTrx delegates transaction to repository database

Jump to

Keyboard shortcuts

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