biz

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 15 Imported by: 0

README

Biz

Documentation

Index

Constants

View Source
const (
	InstanceStatusStarting int8 = iota
	InstanceStatusRunning
	InstanceStatusTerminal
	InstanceStatusExpire
)

Variables

View Source
var (
	// ErrUserNotFound is user not found.
	ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found")
)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID   uuid.UUID
	Name string
}

type AgentRepo

type AgentRepo interface {
	//db
	ListAgent(ctx context.Context) ([]*Agent, error)
	GetAgent(ctx context.Context, id uuid.UUID) (*Agent, error)
	CreateAgent(ctx context.Context, agent *Agent) error
	UpdateAgent(ctx context.Context, id uuid.UUID, agent *Agent) error
	DeleteAgent(ctx context.Context, id uuid.UUID) error
}

type AgentUsecase

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

func NewAgentUsecase

func NewAgentUsecase(repo AgentRepo, logger log.Logger) *AgentUsecase

func (*AgentUsecase) Create

func (uc *AgentUsecase) Create(ctx context.Context, agent *Agent) error

func (*AgentUsecase) Delete

func (uc *AgentUsecase) Delete(ctx context.Context, id uuid.UUID) error

func (*AgentUsecase) Get

func (uc *AgentUsecase) Get(ctx context.Context, id uuid.UUID) (p *Agent, err error)

func (*AgentUsecase) List

func (uc *AgentUsecase) List(ctx context.Context) (ps []*Agent, err error)

func (*AgentUsecase) Update

func (uc *AgentUsecase) Update(ctx context.Context, id uuid.UUID, agent *Agent) error

type ComputeImage

type ComputeImage struct {
	// ID of the ent.
	ID int32 `json:"id,omitempty"`
	// 显示名
	Name string `json:"name,omitempty"`
	// 镜像名
	Image string `json:"image,omitempty"`
	// 版本名
	Tag string `json:"tag,omitempty"`
	// 端口号
	Port int32 `json:"port,omitempty"`
}

type ComputeImageRepo

type ComputeImageRepo interface {
	List(ctx context.Context) ([]*ComputeImage, error)
	Get(ctx context.Context, id int32) (*ComputeImage, error)
}

type ComputeInstance

type ComputeInstance struct {
	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Owner holds the value of the "owner" field.
	Owner string `json:"owner,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Core holds the value of the "core" field.
	Core string `json:"core,omitempty"`
	// Memory holds the value of the "memory" field.
	Memory string `json:"memory,omitempty"`
	// Image holds the value of the "image" field.
	Image string `json:"image,omitempty"`
	// ExpirationTime holds the value of the "expiration_time" field.
	ExpirationTime time.Time `json:"expiration_time,omitempty"`
	// 0: 启动中,1:运行中,2:连接中断, 3:过期
	Status int8 `json:"status,omitempty"`
	// 容器id
	ContainerID string `json:"container_id,omitempty"`
	// p2p agent Id
	PeerID string `json:"peer_id,omitempty"`
}

type ComputeInstanceCreate

type ComputeInstanceCreate struct {
	SpecId   int32
	ImageId  int32
	Duration int32
	Name     string
}

type ComputeInstanceRepo

type ComputeInstanceRepo interface {
	List(ctx context.Context, owner string) ([]*ComputeInstance, error)
	Create(ctx context.Context, instance *ComputeInstance) error
	Delete(ctx context.Context, id uuid.UUID) error
}

type ComputeInstanceUsercase

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

func NewComputeInstanceUsercase

func NewComputeInstanceUsercase(specRepo ComputeSpecRepo, instanceRepo ComputeInstanceRepo, imageRepo ComputeImageRepo, logger log.Logger) *ComputeInstanceUsercase

func (*ComputeInstanceUsercase) Create

func (*ComputeInstanceUsercase) Delete

func (uc *ComputeInstanceUsercase) Delete(ctx context.Context, id uuid.UUID) error

func (*ComputeInstanceUsercase) ListComputeImage

func (uc *ComputeInstanceUsercase) ListComputeImage(ctx context.Context) ([]*ComputeImage, error)

func (*ComputeInstanceUsercase) ListComputeSpec

func (uc *ComputeInstanceUsercase) ListComputeSpec(ctx context.Context) ([]*ComputeSpec, error)

type ComputeSpec

type ComputeSpec struct {
	// ID of the ent.
	ID int32 `json:"id,omitempty"`
	// Core holds the value of the "core" field.
	Core string `json:"core,omitempty"`
	// Memory holds the value of the "memory" field.
	Memory string `json:"memory,omitempty"`
}

type ComputeSpecRepo

type ComputeSpecRepo interface {
	List(ctx context.Context) ([]*ComputeSpec, error)
	Get(ctx context.Context, id int32) (*ComputeSpec, error)
}

type Greeter

type Greeter struct {
	Hello string
}

Greeter is a Greeter model.

type GreeterRepo

type GreeterRepo interface {
	Save(context.Context, *Greeter) (*Greeter, error)
	Update(context.Context, *Greeter) (*Greeter, error)
	FindByID(context.Context, int64) (*Greeter, error)
	ListByHello(context.Context, string) ([]*Greeter, error)
	ListAll(context.Context) ([]*Greeter, error)
}

GreeterRepo is a Greater repo.

type GreeterUsecase

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

GreeterUsecase is a Greeter usecase.

func NewGreeterUsecase

func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase

NewGreeterUsecase new a Greeter usecase.

func (*GreeterUsecase) CreateGreeter

func (uc *GreeterUsecase) CreateGreeter(ctx context.Context, g *Greeter) (*Greeter, error)

CreateGreeter creates a Greeter, and returns the new Greeter.

type Storage

type Storage struct {
	ID uuid.UUID `json:"id,omitempty"`
	// Owner holds the value of the "owner" field.
	Owner string `json:"owner,omitempty"`
	// 0: DIR, 1:file
	Type int32 `json:"type,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Cid holds the value of the "cid" field.
	Cid string `json:"cid,omitempty"`
	// size
	Size int32 `json:"size,omitempty"`
	// LastModify holds the value of the "last_modify" field.
	LastModify time.Time `json:"last_modify,omitempty"`

	// ParentID holds the value of the "parent_id" field.
	ParentID string `json:"parent_id,omitempty"`
}

type StorageRepo

type StorageRepo interface {
	ListStorage(ctx context.Context, owner string, parentId string) ([]*Storage, error)
	GetStorage(ctx context.Context, id uuid.UUID) (*Storage, error)
	CreateStorage(ctx context.Context, storage *Storage) error
	UpdateStorage(ctx context.Context, id uuid.UUID, storage *Storage) error
	DeleteStorage(ctx context.Context, id uuid.UUID) error
}

type Storagecase

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

func NewStorageUsecase

func NewStorageUsecase(repo StorageRepo, logger log.Logger) *Storagecase

func (*Storagecase) Create

func (uc *Storagecase) Create(ctx context.Context, storage *Storage) error

func (*Storagecase) Delete

func (uc *Storagecase) Delete(ctx context.Context, id uuid.UUID) error

func (*Storagecase) Get

func (uc *Storagecase) Get(ctx context.Context, id uuid.UUID) (p *Storage, err error)

func (*Storagecase) List

func (uc *Storagecase) List(ctx context.Context, owner string, parentId string) (ps []*Storage, err error)

func (*Storagecase) Update

func (uc *Storagecase) Update(ctx context.Context, id uuid.UUID, storage *Storage) error

type User

type User struct {
	ID uuid.UUID `json:"id,omitempty"`
	// CountryCallCoding holds the value of the "country_call_coding" field.
	CountryCallCoding string `json:"country_call_coding,omitempty"`
	// TelephoneNumber holds the value of the "telephone_number" field.
	TelephoneNumber string `json:"telephone_number,omitempty"`
	// Password holds the value of the "password" field.
	Password string `json:"password,omitempty"`
	// CreateDate holds the value of the "create_date" field.
	CreateDate time.Time `json:"create_date,omitempty"`
	// LastLoginDate holds the value of the "last_login_date" field.
	LastLoginDate time.Time `json:"last_login_date,omitempty"`
	ValidateCode  string    `json:"validate_code"`
	// 用户名
	Name string `json:"name,omitempty"`
	// 头像地址
	Icon string `json:"icon,omitempty"`
}

func (*User) GetFullTelephone

func (u *User) GetFullTelephone() string

type UserRepo

type UserRepo interface {
	ListUser(ctx context.Context, entity User) ([]*User, error)
	GetUser(ctx context.Context, id uuid.UUID) (*User, error)
	GetUserPassword(ctx context.Context, id uuid.UUID) (*User, error)
	CreateUser(ctx context.Context, user *User) error
	UpdateUser(ctx context.Context, id uuid.UUID, user *User) error
	DeleteUser(ctx context.Context, id uuid.UUID) error
	SendValidateCode(ctx context.Context, entity User) error
	GetValidateCode(ctx context.Context, user User) (string, error)
	DeleteValidateCode(ctx context.Context, user User)
	FindUserByFullTelephone(ctx context.Context, countryCallCoding string, telephone string) (*User, error)
}

type UserUsercase

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

func NewUserUsecase

func NewUserUsecase(conf *conf.Auth, repo UserRepo, logger log.Logger) *UserUsercase

func (*UserUsercase) Create

func (uc *UserUsercase) Create(ctx context.Context, user *User) error

func (*UserUsercase) Delete

func (uc *UserUsercase) Delete(ctx context.Context, id uuid.UUID) error

func (*UserUsercase) Get

func (uc *UserUsercase) Get(ctx context.Context, id uuid.UUID) (p *User, err error)

func (*UserUsercase) GetValidateCode

func (uc *UserUsercase) GetValidateCode(ctx context.Context, user User) (string, error)

func (*UserUsercase) List

func (uc *UserUsercase) List(ctx context.Context, entity User) (ps []*User, err error)

func (*UserUsercase) Login

func (uc *UserUsercase) Login(ctx context.Context, user *User) (string, error)

func (*UserUsercase) LoginWithValidateCode

func (uc *UserUsercase) LoginWithValidateCode(ctx context.Context, user *User) (string, error)

func (*UserUsercase) SendValidateCode

func (uc *UserUsercase) SendValidateCode(ctx context.Context, entity User) error

func (*UserUsercase) Update

func (uc *UserUsercase) Update(ctx context.Context, id uuid.UUID, user *User) error

Jump to

Keyboard shortcuts

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