service

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMysqlConn

func CreateMysqlConn(conf *config.Config) (*gorm.DB, error)

func IsFormAPI

func IsFormAPI(path string) bool

Types

type AssignRoleGrantReq

type AssignRoleGrantReq struct {
	Add     []*Owners `json:"add"`
	RoleID  string    `json:"roleID"`
	AppID   string    `json:"appID"`
	Removes []string  `json:"removes"`
}

type AssignRoleGrantResp

type AssignRoleGrantResp struct{}

type Backup

type Backup interface {
	ExportTable(context.Context, *ExportReq) (*ExportResp, error)
	ExportPermit(context.Context, *ExportReq) (*ExportResp, error)
	ExportTableRelation(context.Context, *ExportReq) (*ExportResp, error)
	ExportTableScheme(context.Context, *ExportReq) (*ExportResp, error)
	ExportRole(context.Context, *ExportReq) (*ExportResp, error)

	ImportTable(context.Context, *ImportReq) (*ImportResp, error)
	ImportPermit(context.Context, *ImportReq) (*ImportResp, error)
	ImportTableRelation(context.Context, *ImportReq) (*ImportResp, error)
	ImportTableScheme(context.Context, *ImportReq) (*ImportResp, error)
	ImportRole(context.Context, *ImportReq) (*ImportResp, error)
}

Backup import and export data interface.

func NewBackup

func NewBackup(conf *config2.Config) (Backup, error)

NewBackup create a new backup service.

type CopyRoleReq

type CopyRoleReq struct {
	RoleID      string `json:"roleID"`
	UserID      string `json:"userID"`
	AppID       string `json:"appID"`
	UserName    string `json:"userName"`
	Description string `json:"description"`
	Name        string `json:"name"`
}

type CopyRoleResp

type CopyRoleResp struct {
	RoleID string `json:"id"`
}

type CreatePerReq

type CreatePerReq struct {
	AccessPath string             `json:"path"`
	URI        string             `json:"uri"`
	Params     models.FiledPermit `json:"params"`
	Response   models.FiledPermit `json:"response"`
	Condition  models.Condition   `json:"condition"`
	RoleID     string             `json:"roleID"`
	UserID     string             `json:"userID"`
	UserName   string             `json:"userName"`
	Method     string             `json:"method"`
}

type CreatePerResp

type CreatePerResp struct{}

type CreateRoleReq

type CreateRoleReq struct {
	UserID      string          `json:"user_id"`
	UserName    string          `json:"user_name"`
	AppID       string          `json:"app_id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Types       models.RoleType `json:"types"`
}

type CreateRoleResp

type CreateRoleResp struct {
	ID string `json:"id"`
}

type CreateUserRoleReq

type CreateUserRoleReq struct {
	RoleID string `json:"roleID"`
	UserID string `json:"userID"`
	AppID  string `json:"appID"`
}

type CreateUserRoleResp

type CreateUserRoleResp struct{}

type DeletePerReq

type DeletePerReq struct {
	RoleID string `json:"roleID"`
	Path   string `json:"path"`
	URI    string `json:"uri"`
	Method string `json:"method"`
}

type DeletePerResp

type DeletePerResp struct{}

type DeleteRoleReq

type DeleteRoleReq struct {
	RoleID string `json:"-"`
	AppID  string `json:"-"`
}

type DeleteRoleResp

type DeleteRoleResp struct{}

type ExportReq

type ExportReq struct {
	AppID string `uri:"appID"`
	Page  int    `json:"page"`
	Size  int    `json:"size"`
}

ExportReq export request.

type ExportResp

type ExportResp struct {
	Data  Object `json:"data"`
	Count int64  `json:"count"`
}

ExportResp export response.

type FindGrantRoleReq

type FindGrantRoleReq struct {
	Owners []string `json:"owners"`
	AppID  string   `json:"appID"`
	RoleID string   `json:"roleID"`
	Page   int      `json:"page"`
	Size   int      `json:"size"`
	Types  int      `json:"type"`
}

type FindGrantRoleResp

type FindGrantRoleResp struct {
	List  []*GrantRoles `json:"list"`
	Total int64         `json:"total"`
}

type FindPermitReq

type FindPermitReq struct {
	RoleID string `json:"roleID"`
	Page   int    `json:"page"`
	Size   int    `json:"size"`
}

type FindPermitResp

type FindPermitResp struct {
	List  []*Permits `json:"list"`
	Total int64      `json:"total"`
}

type FindRoleReq

type FindRoleReq struct {
	AppID string `json:"appID"`
	Page  int    `json:"page"`
	Size  int    `json:"size"`
}

type FindRoleResp

type FindRoleResp struct {
	List  []*roleVo `json:"list"`
	Total int64     `json:"total"`
}

type GetPermitReq

type GetPermitReq struct {
	RoleID string `json:"roleID"`
	Path   string `json:"path"`
	URI    string `json:"uri"`
	Method string `json:"method" binding:"required"`
}

type GetPermitResp

type GetPermitResp struct {
	ID          string             `json:"id"`
	RoleID      string             `json:"roleID"`
	Path        string             `json:"path,omitempty"`
	Params      models.FiledPermit `json:"params,omitempty"`
	Response    models.FiledPermit `json:"response,omitempty"`
	Condition   models.Condition   `json:"condition,omitempty"`
	ResponseAll bool               `json:"responseAll"`
	ParamsAll   bool               `json:"paramsAll"`
}

type GetRoleReq

type GetRoleReq struct {
	ID string `json:"id"`
}

type GetRoleResp

type GetRoleResp struct {
	Types       models.RoleType `json:"type"`
	ID          string          `json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
}

type GetUserRoleReq

type GetUserRoleReq struct {
	UserID string `json:"userID"`
	DepID  string `json:"depID"`
	AppID  string `json:"appID"`
}

type GetUserRoleResp

type GetUserRoleResp struct {
	RoleID string          `json:"id"`
	Types  models.RoleType `json:"type"`
}

type GrantRoles

type GrantRoles struct {
	RoleID    string `json:"roleID"`
	Owner     string `json:"id"`
	OwnerName string `json:"name"`
	Types     int    `json:"type"`
}

type ImportReq

type ImportReq struct {
	Data Object `json:"data"`
}

ImportReq import request.

type ImportResp

type ImportResp struct{}

ImportResp import response.

type ListAndSelectReq

type ListAndSelectReq struct {
	AppID  string `json:"appID"`
	UserID string `json:"userID"`
	DepID  string `json:"depID"`
}

type ListAndSelectResp

type ListAndSelectResp struct {
	OptionPer []*Per `json:"optionPer"`
	SelectPer *Per   `json:"selectPer"`
}

type ListPermitReq

type ListPermitReq struct {
	RoleID string     `json:"roleID"`
	List   []*ListRes `json:"paths" binding:"required"`
}

type ListPermitResp

type ListPermitResp map[string]bool

type ListRes

type ListRes struct {
	URI        string `json:"uri"`
	AccessPath string `json:"accessPath"`
	Method     string `json:"method"`
}

type Object

type Object []interface{}

Object export data type.

type Option

type Option func(ctx context.Context, req *OptionReq)

Option Option

func RoleUserOption

func RoleUserOption(permit2 Permit) Option

type OptionReq

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

type Owners

type Owners struct {
	Owner     string `json:"id"`
	OwnerName string `json:"name"`
	Types     int    `json:"type"`
}

type Per

type Per struct {
	RoleID   string `json:"roleID"`
	RoleName string `json:"roleName"`
}

type Permit

type Permit interface {
	CreateRole(ctx context.Context, req *CreateRoleReq) (*CreateRoleResp, error)

	UpdateRole(ctx context.Context, req *UpdateRoleReq) (*UpdateRoleResp, error)

	DeleteRole(ctx context.Context, req *DeleteRoleReq) (*DeleteRoleResp, error) // 这个删除需要关心的东西比较多

	GetRole(ctx context.Context, req *GetRoleReq) (*GetRoleResp, error)

	FindRole(ctx context.Context, req *FindRoleReq) (*FindRoleResp, error)

	AssignRoleGrant(ctx context.Context, req *AssignRoleGrantReq) (*AssignRoleGrantResp, error)

	FindGrantRole(ctx context.Context, req *FindGrantRoleReq) (*FindGrantRoleResp, error)

	CreatePermit(ctx context.Context, req *CreatePerReq) (*CreatePerResp, error)

	UpdatePermit(ctx context.Context, req *UpdatePerReq) (*UpdatePerResp, error)

	DeletePermit(ctx context.Context, req *DeletePerReq) (*DeletePerResp, error)

	GetPermit(ctx context.Context, req *GetPermitReq) (*GetPermitResp, error)

	FindPermit(ctx context.Context, req *FindPermitReq) (*FindPermitResp, error)

	CreateUserRole(ctx context.Context, req *CreateUserRoleReq, opts ...Option) (*CreateUserRoleResp, error)

	ListPermit(ctx context.Context, req *ListPermitReq) (*ListPermitResp, error)

	ListAndSelect(ctx context.Context, req *ListAndSelectReq) (*ListAndSelectResp, error)

	GetUserRole(ctx context.Context, req *GetUserRoleReq) (*GetUserRoleResp, error)

	CopyRole(ctx context.Context, req *CopyRoleReq) (*CopyRoleResp, error)
}

func NewPermit

func NewPermit(conf *config2.Config) (Permit, error)

type Permits

type Permits struct {
	ID        string             `json:"id"`
	RoleID    string             `json:"roleID"`
	Path      string             `json:"path"`
	Params    models.FiledPermit `json:"params"`
	Response  models.FiledPermit `json:"response"`
	Condition models.Condition   `json:"condition"`
	Methods   string             `json:"methods"`
}

type UpdatePerReq

type UpdatePerReq struct {
	ID          string             `json:"id"`
	Params      models.FiledPermit `json:"params"`
	Response    models.FiledPermit `json:"response"`
	Condition   models.Condition   `json:"condition"`
	ParamsAll   bool               `json:"paramsAll"`
	ResponseAll bool               `json:"responseAll"`
	Path        string             `json:"accessPath"`
	URI         string             `json:"uri"`
	Method      string             `json:"method"`
}

type UpdatePerResp

type UpdatePerResp struct{}

type UpdateRoleReq

type UpdateRoleReq struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type UpdateRoleResp

type UpdateRoleResp struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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