model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

@Time : 2019-08-27 14:57 @Author : zr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory added in v1.1.0

type Memory struct {
	Services map[string]*Service
	Roles    map[string]*Role
	sync.Mutex
	SyncErr error
	// contains filtered or unexported fields
}

func NewMemory added in v1.1.0

func NewMemory(storage Storage) Memory

func (*Memory) DeleteRole added in v1.1.0

func (m *Memory) DeleteRole(name string) (err error)

func (*Memory) DeleteService added in v1.1.0

func (m *Memory) DeleteService(name string) (err error)

func (*Memory) NewRole added in v1.1.0

func (m *Memory) NewRole(name string, description string) (r *Role, err error)

func (*Memory) NewService added in v1.1.0

func (m *Memory) NewService(servicePath, description string) (service *Service, err error)

func (*Memory) RoleUpdateServices added in v1.1.0

func (m *Memory) RoleUpdateServices(roleName string, servicePaths ...string) (err error)

func (*Memory) Sync added in v1.1.0

func (m *Memory) Sync()

type Role

type Role struct {
	Name        string
	Description string
	EditTime    time.Time
	CreateTime  time.Time
	Status      Status
	Services    []*Service `gorm:"-"`
	// contains filtered or unexported fields
}

func (*Role) SetDescription added in v1.1.0

func (r *Role) SetDescription(description string) error

func (*Role) SetMemory added in v1.1.0

func (r *Role) SetMemory(memory *Memory)

func (*Role) SetServices added in v1.1.0

func (r *Role) SetServices(servicePath ...string) (err error)

func (*Role) SetStatus added in v1.1.0

func (r *Role) SetStatus(status Status) error

type Service

type Service struct {
	Path        string
	Description string
	CreateTime  time.Time
	EditTime    time.Time
	Status      Status
	// contains filtered or unexported fields
}

func (*Service) NewSubService

func (s *Service) NewSubService(name, description string) (service *Service, err error)

func (*Service) SetDescription added in v1.1.0

func (s *Service) SetDescription(description string) error

func (*Service) SetMemory added in v1.1.0

func (s *Service) SetMemory(memory *Memory)

func (*Service) SetStatus added in v1.1.0

func (s *Service) SetStatus(status Status) error

type Status added in v1.1.0

type Status int
const (
	StatusOff Status = -1

	StatusOn Status
)

type Storage

type Storage interface {
	Sync(memory *Memory) (err error)
	RoleUpdate(role *Role) error
	RoleCreate(role *Role) (err error)
	RoleDelete(name string) (err error)
	ServiceUpdate(service *Service) (err error)
	ServiceCreate(service *Service) (err error)
	ServiceDelete(name string) (err error)
	UpdateRelation(role *Role, service []*Service) error
}

type User added in v1.1.0

type User struct {
	Id         int    `gorm:"type:char(100)"`
	UserCode   string `gorm:"type:varchar(100)"`
	Name       string `gorm:"type:varchar(100)"`
	Password   string `gorm:"type:varchar(100)"`
	Status     UserStatus
	Memo       string `gorm:"type:varchar(500)"`
	EditTime   *time.Time
	CreateTime *time.Time
	DeleteAt   *time.Time
}

func (User) TableName added in v1.1.0

func (User) TableName() string

type UserRole added in v1.1.0

type UserRole struct {
	UserId     int
	Role       string
	EditTime   *time.Time
	CreateTime *time.Time
}

func (UserRole) TableName added in v1.1.0

func (UserRole) TableName() string

type UserStatus added in v1.1.0

type UserStatus int
const (
	UserStatusBan UserStatus = -1

	UserStatusNormal UserStatus
)

Jump to

Keyboard shortcuts

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