biz

package
v0.0.0-...-29cb976 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPageSize is the maximum page size that can be returned by a List call. Requesting page sizes larger than
	// this value will return, at most, MaxPageSize entries.
	MaxPageSize = 1000

	// MaxBatchCreateSize is the maximum number of entries that can be created by a single BatchCreate call. Requests
	// exceeding this batch size will return an error.
	MaxBatchCreateSize = 1000

	// MaxBatchUpdateSize is the maximum number of entries that can be updated by a single BatchUpdate call. Requests
	// exceeding this batch size will return an error.
	MaxBatchUpdateSize = 1000
)

Variables

ProviderSet is biz providers.

Functions

func ToProtoGroup

func ToProtoGroup(g *Group) (*v1.Group, error)

func ToProtoGroupList

func ToProtoGroupList(g []*Group) ([]*v1.Group, error)

func ToProtoUser

func ToProtoUser(u *User) (*v1.User, error)

func ToProtoUserList

func ToProtoUserList(u []*User) ([]*v1.User, error)

Types

type Group

type Group struct {
	Id          int64     `json:"id,omitempty"`
	Name        string    `json:"name,omitempty"`
	MaxStorage  uint64    `json:"maxStorage,omitempty"`
	ShareEnable bool      `json:"shareEnable,omitempty"`
	SpeedLimit  int64     `json:"speedLimit,omitempty"`
	CreateAt    time.Time `json:"createAt"`
	UpdateAt    time.Time `json:"updateAt"`
	Users       []*User   `json:"users,omitempty"`
}

func ToGroup

func ToGroup(p *v1.Group) (*Group, error)

func ToGroupList

func ToGroupList(p []*v1.Group) ([]*Group, error)

type GroupPage

type GroupPage struct {
	Groups        []*Group
	NextPageToken string
}

type GroupRepo

type GroupRepo interface {
	Create(ctx context.Context, group *Group) (*Group, error)
	Get(ctx context.Context, groupId int64, groupView GroupView) (*Group, error)
	GetByName(ctx context.Context, name string, groupView GroupView) (*Group, error)
	Update(ctx context.Context, group *Group) (*Group, error)
	Delete(ctx context.Context, groupId int64) error
	List(ctx context.Context, pageSize int, pageToken string, groupView GroupView) (*GroupPage, error)
	BatchCreate(ctx context.Context, groups []*Group) ([]*Group, error)
}

type GroupUsecase

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

func NewGroupUsecase

func NewGroupUsecase(repo GroupRepo, logger log.Logger) *GroupUsecase

func (*GroupUsecase) CreateGroup

func (uc *GroupUsecase) CreateGroup(ctx context.Context, group *Group) (*v1.Group, error)

func (*GroupUsecase) DeleteGroup

func (uc *GroupUsecase) DeleteGroup(ctx context.Context, groupId int64) error

func (*GroupUsecase) GetGroup

func (uc *GroupUsecase) GetGroup(ctx context.Context, groupId int64, view GroupView) (*v1.Group, error)

func (*GroupUsecase) ListGroups

func (uc *GroupUsecase) ListGroups(
	ctx context.Context,
	pageSize int,
	pageToken string,
	view GroupView,
) ([]*v1.Group, string, error)

func (*GroupUsecase) UpdateGroup

func (uc *GroupUsecase) UpdateGroup(ctx context.Context, group *Group) (*v1.Group, error)

type GroupView

type GroupView int32
const (
	GroupViewViewUnspecified GroupView = 0
	GroupViewBasic           GroupView = 1
	GroupViewWithEdgeIds     GroupView = 2
)

type Setting

type Setting struct {
	Id    int64        `json:"id,omitempty"`
	Name  *string      `json:"name,omitempty"`
	Value *string      `json:"value,omitempty"`
	Type  *SettingType `json:"type,omitempty"`
}

type SettingName

type SettingName string
const (
	RegisterEnable       SettingName = "register_enable"
	RegisterDefaultGroup SettingName = "register_default_group"
	RegisterMailActive   SettingName = "register_mail_active"
	// RegisterMailFilter Indicates the status of the mail filter. "off" indicates that the mail filter
	// is disabled, "blacklist" indicates the blacklist, and "whitelist" indicates the whitelist
	RegisterMailFilter     SettingName = "register_mail_filter"
	RegisterMailFilterList SettingName = "register_mail_filter_list"
)

type SettingRepo

type SettingRepo interface {
	Create(ctx context.Context, s *Setting) (*Setting, error)
	Get(ctx context.Context, id int64) (*Setting, error)
	GetByName(ctx context.Context, name string) (*Setting, error)
	Update(ctx context.Context, s *Setting) (*Setting, error)
	Delete(ctx context.Context, id int64) error
	List(ctx context.Context) (map[SettingName]*Setting, error)
	ListByType(ctx context.Context, t SettingType) (map[SettingName]*Setting, error)
	BatchCreate(ctx context.Context, settings []*Setting) ([]*Setting, error)
	BatchUpsert(ctx context.Context, settings []*Setting) error
}

type SettingType

type SettingType string
const (
	TypeBasic    SettingType = "basic"
	TypeRegister SettingType = "register"
	TypeLogin    SettingType = "login"
	TypeMail     SettingType = "mail"
	TypeCaptcha  SettingType = "captcha"
	TypePwa      SettingType = "pwa"
	TypeTimeout  SettingType = "timeout"
	TypeUpload   SettingType = "upload"
	TypeShare    SettingType = "share"
	TypeAvatar   SettingType = "avatar"
	TypePayment  SettingType = "payment"
	TypeScore    SettingType = "score"
	TypeTask     SettingType = "task"
	TypeAuth     SettingType = "auth"
	TypeCron     SettingType = "cron"
)

func (SettingType) String

func (s SettingType) String() string

type SettingUsecase

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

func NewSettingUsecase

func NewSettingUsecase(repo SettingRepo, logger log.Logger) *SettingUsecase

type User

type User struct {
	Id         int64      `json:"id,omitempty"`
	GroupId    int64      `json:"groupId,omitempty"`
	Email      string     `json:"email,omitempty"`
	NickName   string     `json:"nickName,omitempty"`
	Salt       []byte     `json:"salt,omitempty"`
	Verifier   []byte     `json:"verifier,omitempty"`
	Storage    uint64     `json:"storage,omitempty"`
	Score      int64      `json:"score,omitempty"`
	Status     UserStatus `json:"status,omitempty"`
	CreateAt   time.Time  `json:"createAt"`
	UpdateAt   time.Time  `json:"updateAt"`
	OwnerGroup *Group     `json:"ownerGroup,omitempty"`
}

func ToUser

func ToUser(p *v1.User) (*User, error)

func ToUserList

func ToUserList(p []*v1.User) ([]*User, error)

type UserPage

type UserPage struct {
	Users         []*User
	NextPageToken string
}

type UserRepo

type UserRepo interface {
	Create(ctx context.Context, user *User) (*User, error)
	Get(ctx context.Context, userId int64, userView UserView) (*User, error)
	GetByEmail(ctx context.Context, email string, userView UserView) (*User, error)
	Update(ctx context.Context, user *User) (*User, error)
	Delete(ctx context.Context, userId int64) error
	List(ctx context.Context, pageSize int, pageToken string, userView UserView) (*UserPage, error)
	BatchCreate(ctx context.Context, users []*User) ([]*User, error)

	IsAdminUser(ctx context.Context, userId int64) (bool, error)

	CacheSRPServer(ctx context.Context, email string, server *srp.Server) error
	GetSRPServer(ctx context.Context, email string) (*srp.Server, error)
}

type UserStatus

type UserStatus string
const (
	StatusNonActivated UserStatus = "non_activated"
	StatusActive       UserStatus = "active"
	StatusBanned       UserStatus = "banned"
	StatusOveruseBaned UserStatus = "overuse_baned"
)

Status values.

func (UserStatus) String

func (s UserStatus) String() string

type UserUsecase

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

func NewUserUsecase

func NewUserUsecase(ur UserRepo, gr GroupRepo, sr SettingRepo, params *srp.Params, logger log.Logger) *UserUsecase

func (*UserUsecase) DeleteUser

func (uc *UserUsecase) DeleteUser(ctx context.Context, userId int64) error

func (*UserUsecase) GetUser

func (uc *UserUsecase) GetUser(ctx context.Context, userId int64) (*v1.User, error)

func (*UserUsecase) GetUserSalt

func (uc *UserUsecase) GetUserSalt(ctx context.Context, email string) ([]byte, error)

func (*UserUsecase) IsAdminUser

func (uc *UserUsecase) IsAdminUser(ctx context.Context, userId int64) (bool, error)

func (*UserUsecase) ListUsers

func (uc *UserUsecase) ListUsers(
	ctx context.Context,
	pageSize int,
	pageToken string,
	view UserView,
) ([]*v1.User, string, error)

func (*UserUsecase) SigninA

func (uc *UserUsecase) SigninA(ctx context.Context, email string, a []byte) ([]byte, error)

func (*UserUsecase) SigninM

func (uc *UserUsecase) SigninM(ctx context.Context, email string, m1 []byte) (userid int64, k []byte, err error)

func (*UserUsecase) Signup

func (uc *UserUsecase) Signup(ctx context.Context, email string, salt, verifier []byte) (*v1.User, error)

func (*UserUsecase) UpdateUser

func (uc *UserUsecase) UpdateUser(ctx context.Context, user *User) (*v1.User, error)

type UserView

type UserView int32
const (
	UserViewViewUnspecified UserView = 0
	UserViewBasic           UserView = 1
	UserViewWithEdgeIds     UserView = 2
)

Jump to

Keyboard shortcuts

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