data

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is data providers.

Functions

func NewApiRepo

func NewApiRepo(data *Data, logger log.Logger) biz.ApiRepo

func NewCasbinRepo

func NewCasbinRepo(data *Data, conf *conf.Bootstrap, logger log.Logger) biz.CasbinRepo

func NewMenuRepo

func NewMenuRepo(data *Data, logger log.Logger) biz.MenuRepo

func NewMysqlCmd

func NewMysqlCmd(conf *conf.Bootstrap, logger log.Logger) *gorm.DB

func NewRedisClient

func NewRedisClient(conf *conf.Data) *redis.Client

func NewRedisCmd

func NewRedisCmd(conf *conf.Data, logger log.Logger) redis.Cmdable

func NewRoleRepo

func NewRoleRepo(data *Data, logger log.Logger) biz.RoleRepo

func Paginate

func Paginate(page, pageSize int64) func(db *gorm.DB) *gorm.DB

Paginate 分页

Types

type ApiEntity

type ApiEntity struct {
	BaseFields
	Domain string `gorm:"type:varchar(255);not null;comment:所在域"`
	Name   string `gorm:"type:varchar(255);not null;comment:名称"`
	Group  string `gorm:"type:varchar(255);not null;comment:分组"`
	Method string `gorm:"type:varchar(255);not null;comment:请求方式"`
	Path   string `gorm:"type:varchar(255);not null;comment:请求路径"`
}

func (ApiEntity) TableName

func (ApiEntity) TableName() string

type ApiRepo

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

func (ApiRepo) CreateApi

func (repo ApiRepo) CreateApi(ctx context.Context, api *domain.Api) (*domain.Api, error)

func (ApiRepo) DeleteApi

func (repo ApiRepo) DeleteApi(ctx context.Context, domain *domain.Api) error

func (ApiRepo) GetApi

func (repo ApiRepo) GetApi(ctx context.Context, params map[string]interface{}) (*domain.Api, error)

func (ApiRepo) GetApiByParams

func (repo ApiRepo) GetApiByParams(ctx context.Context, params map[string]interface{}) (record *ApiEntity, err error)

func (ApiRepo) GetApiCount

func (repo ApiRepo) GetApiCount(ctx context.Context, params map[string]interface{}) int64

func (ApiRepo) ListApi

func (repo ApiRepo) ListApi(ctx context.Context, page, pageSize int64, params map[string]interface{}) ([]*domain.Api, int64, error)

func (ApiRepo) ListApiAll

func (repo ApiRepo) ListApiAll(ctx context.Context) ([]*domain.Api, error)

func (ApiRepo) UpdateApi

func (repo ApiRepo) UpdateApi(ctx context.Context, api *domain.Api) error

type BaseFields

type BaseFields struct {
	Id        int64          `gorm:"primarykey;type:int;comment:主键id"`
	CreatedAt time.Time      `gorm:"column:created_at;not null;comment:创建时间"`
	UpdatedAt time.Time      `gorm:"column:updated_at;not null;comment:更新时间"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间"`
}

type CasbinEntity

type CasbinEntity struct {
	ID     int64  `json:"id"`
	PType  string `json:"ptype" gorm:"column:p_type" `
	Role   string `json:"role_name" gorm:"column:v0" `
	Path   string `json:"path" gorm:"column:v1" `
	Method string `json:"method" gorm:"column:v2" `
}

func (CasbinEntity) TableName

func (CasbinEntity) TableName() string

type CasbinRepo

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

func (CasbinRepo) CheckAuthorization

func (a CasbinRepo) CheckAuthorization(ctx context.Context, sub, obj, act string) (bool, error)

func (CasbinRepo) DeleteRoleForUser

func (r CasbinRepo) DeleteRoleForUser(ctx context.Context, username string, Casbin string) (bool, error)

func (CasbinRepo) DeleteRolesForUser

func (r CasbinRepo) DeleteRolesForUser(ctx context.Context, username string) (bool, error)

func (CasbinRepo) GetPolicies

func (r CasbinRepo) GetPolicies(ctx context.Context, role string) ([]*biz.PolicyRules, error)

func (CasbinRepo) GetRolesForUser

func (r CasbinRepo) GetRolesForUser(ctx context.Context, username string) ([]string, error)

func (CasbinRepo) GetUsersForRole

func (r CasbinRepo) GetUsersForRole(ctx context.Context, Casbin string) ([]string, error)

func (CasbinRepo) SetRolesForUser

func (r CasbinRepo) SetRolesForUser(ctx context.Context, username string, Roles []string) (bool, error)

func (CasbinRepo) UpdatePolicies

func (r CasbinRepo) UpdatePolicies(ctx context.Context, role string, rules []biz.PolicyRules) (bool, error)

type Data

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

Data .

func NewData

func NewData(cfg *conf.Bootstrap, db *gorm.DB, redisCli *redis.Client, logger log.Logger) (*Data, func(), error)
type MenuBtnEntity struct {
	Id          int64     `gorm:"primarykey;type:int;comment:主键id"`
	Domain      string    `gorm:"type:varchar(255);not null;comment:所在域"`
	MenuId      int64     `gorm:"type:int;comment:菜单id"`
	Name        string    `gorm:"type:varchar(255);not null;comment:按钮名称"`
	Description string    `gorm:"type:varchar(255);not null;comment:描述"`
	Identifier  string    `gorm:"type:varchar(255);not null;comment:英文标识"`
	CreatedAt   time.Time `gorm:"column:created_at;not null;comment:创建时间"`
	UpdatedAt   time.Time `gorm:"column:updated_at;not null;comment:更新时间"`
}
func (MenuBtnEntity) TableName() string
type MenuEntity struct {
	BaseFields
	Domain    string           `gorm:"type:varchar(255);not null;comment:所在域"`
	ParentId  int64            `gorm:"type:int;comment:父级id"`
	ParentIds string           `gorm:"type:varchar(255);comment:父级id字符串 英文逗号分割"`
	Name      string           `gorm:"type:varchar(255);not null;comment:菜单名"`
	Path      string           `gorm:"type:varchar(255);not null;comment:前端路径"`
	Hidden    bool             `gorm:"not null;comment:是否隐藏 0否1是"`
	Component string           `gorm:"type:varchar(255);not null;comment:前端文件路径"`
	Sort      int64            `gorm:"type:int;comment:排序"`
	Title     string           `gorm:"type:varchar(255);not null;comment:页面名称"`
	Icon      string           `gorm:"type:varchar(255);not null;comment:菜单图标"`
	MenuBtns  []*MenuBtnEntity `gorm:"foreignKey:menu_id;"`
	Children  []MenuEntity     `gorm:"-"`
}
func (MenuEntity) TableName() string
type MenuRepo struct {
	// contains filtered or unexported fields
}
func (r MenuRepo) CreateMenu(ctx context.Context, reqData *domain.Menu) (*domain.Menu, error)
func (r MenuRepo) DeleteMenu(ctx context.Context, id int64) error
func (r MenuRepo) GetMenuAll(ctx context.Context) ([]*domain.Menu, error)
func (r MenuRepo) GetMenuTree(ctx context.Context) ([]*domain.Menu, error)
func (r MenuRepo) GetRoleMenu(ctx context.Context, role string) ([]*domain.Menu, error)
func (r MenuRepo) GetRoleMenuBtn(ctx context.Context, roleId int64, roleName string, menuId int64) (response []*domain.MenuBtn, err error)
func (r MenuRepo) GetRoleMenuTree(ctx context.Context, role string) ([]*domain.Menu, error)
func (r MenuRepo) SaveRoleMenu(ctx context.Context, roleId int64, menuIds []int64) error
func (r MenuRepo) SaveRoleMenuBtn(ctx context.Context, roleId int64, menuId int64, btnIds []int64) error
func (r MenuRepo) UpdateMenu(ctx context.Context, reqData *domain.Menu) error

type RoleEntity

type RoleEntity struct {
	BaseFields
	Domain string `gorm:"type:varchar(255);not null;comment:所在域"`
	Name   string `gorm:"type:varchar(255);not null;comment:名称"`
}

func (RoleEntity) TableName

func (RoleEntity) TableName() string

type RoleMenuBtnEntity

type RoleMenuBtnEntity struct {
	Id     int64  `gorm:"primarykey;type:int;comment:主键id"`
	Domain string `gorm:"type:varchar(255);not null;comment:所在域"`
	RoleId int64  `gorm:"type:int;comment:角色id"`
	MenuId int64  `gorm:"type:int;comment:菜单id"`
	BtnId  int64  `gorm:"type:int;comment:按钮id"`
}

func (RoleMenuBtnEntity) TableName

func (RoleMenuBtnEntity) TableName() string

type RoleMenuEntity

type RoleMenuEntity struct {
	Id     int64  `gorm:"primarykey;type:int;comment:主键id"`
	Domain string `gorm:"type:varchar(255);not null;comment:所在域"`
	RoleId int64  `gorm:"type:int;comment:角色id"`
	MenuId int64  `gorm:"type:int;comment:菜单id"`
}

func (RoleMenuEntity) TableName

func (RoleMenuEntity) TableName() string

type RoleRepo

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

func (RoleRepo) CreateRole

func (r RoleRepo) CreateRole(ctx context.Context, role *domain.Role) (*domain.Role, error)

func (RoleRepo) DeleteRole

func (r RoleRepo) DeleteRole(ctx context.Context, role *domain.Role) error

func (RoleRepo) GetRole

func (r RoleRepo) GetRole(ctx context.Context, params map[string]interface{}) (*domain.Role, error)

func (RoleRepo) GetRoleByParams

func (r RoleRepo) GetRoleByParams(ctx context.Context, params map[string]interface{}) (record *RoleEntity, err error)

func (RoleRepo) ListRoleAll

func (r RoleRepo) ListRoleAll(ctx context.Context) ([]*domain.Role, error)

func (RoleRepo) UpdateRole

func (r RoleRepo) UpdateRole(ctx context.Context, role *domain.Role) error

Jump to

Keyboard shortcuts

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