control

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetMissingTag = errors.New("asset is missing a tag")
View Source
var ErrAssetNotFound = errors.New("asset not found")
View Source
var ErrDeleteAsset = errors.New("error deleting asset")
View Source
var ErrFileNotFound = errors.New("file not found")
View Source
var ErrInvalidCredentials = errors.New("invalid credentials")
View Source
var ErrInvalidTag = errors.New("invalid tag")
View Source
var ErrPasswordEmpty = errors.New("password must not be empty")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var ErrUsernameEmpty = errors.New("username must not be empty")

Functions

This section is empty.

Types

type AssetControl

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

func NewAssetControl

func NewAssetControl(db *database.Database, tags *TagControl, files *FileControl, repo AssetRepo) *AssetControl

func (*AssetControl) Create

func (ac *AssetControl) Create(ctx context.Context, cmd CreateAssetCmd) (*entities.Asset, error)

func (*AssetControl) Delete

func (ac *AssetControl) Delete(ctx context.Context, asset *entities.Asset) error

func (*AssetControl) Get

func (ac *AssetControl) Get(ctx context.Context, query GetAssetQuery) (*entities.Asset, error)

func (*AssetControl) List

func (*AssetControl) Update

func (ac *AssetControl) Update(ctx context.Context, cmd UpdateAssetCmd) (*entities.Asset, error)

type AssetRepo

type AssetRepo interface {
	Get(ctx context.Context, exec bob.Executor, query database.GetAssetQuery) (*entities.Asset, error)
	List(ctx context.Context, exec bob.Executor, query database.ListAssetsQuery) (*entities.ListPage[*entities.Asset], error)
	Create(ctx context.Context, exec bob.Executor, asset *entities.Asset) error
	Update(ctx context.Context, exec bob.Executor, asset *entities.Asset) error
	Delete(ctx context.Context, exec bob.Executor, id int64) error
}

type AuthConfig

type AuthConfig struct {
	Argon2Params auth.Argon2Params
}

type AuthController

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

func NewAuthController

func NewAuthController(config AuthConfig, db *database.Database, users *UserControl, localAuth LocalAuthRepo) *AuthController

func (*AuthController) ChangeUserCredentials

func (ac *AuthController) ChangeUserCredentials(ctx context.Context, cmd ChangeUserCredentialsCmd) (map[string]string, error)

func (*AuthController) CreateUser

func (ac *AuthController) CreateUser(ctx context.Context, cmd CreateUserCmd) error

func (*AuthController) DeleteUser

func (ac *AuthController) DeleteUser(ctx context.Context, userID int64) error

func (*AuthController) GetUserForCredentials

func (ac *AuthController) GetUserForCredentials(ctx context.Context, query GetUserForCredentialsQuery) (*auth.User, map[string]string, error)

func (*AuthController) ResetPassword

func (ac *AuthController) ResetPassword(ctx context.Context, cmd ResetPasswordCmd) error

func (*AuthController) ToggleAdmin

func (ac *AuthController) ToggleAdmin(ctx context.Context, id int64) error

type CategoryCtrl

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

func NewCategoryCtrl

func NewCategoryCtrl(db *database.Database, repo CategoryRepo) *CategoryCtrl

func (*CategoryCtrl) List

type CategoryRepo

type CategoryRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListCategoriesQuery) (*entities.ListPage[*entities.Category], error)
}

type ChangeUserCredentialsCmd

type ChangeUserCredentialsCmd struct {
	User                     *auth.User
	CurrPasswdPlaintext      string
	NewPasswdPlaintext       string
	NewPasswdRepeatPlaintext string
}

type CreateAssetCmd

type CreateAssetCmd struct {
	Asset *entities.Asset
	Image *entities.File
}

type CreateUserCmd

type CreateUserCmd struct {
	User            *auth.User
	PlaintextPasswd string
}

type CustomAttrCtrl

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

func NewCustomAttrCtrl

func NewCustomAttrCtrl(db *database.Database, repo CustomAttrRepo) *CustomAttrCtrl

func (*CustomAttrCtrl) List

type CustomAttrRepo

type CustomAttrRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListCustomAttrsQuery) (*entities.ListPage[*entities.CustomAttr], error)
}

type ExportCmd

type ExportCmd struct {
	Format string
}

type ExporterCtrl

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

func NewExporterCtrl

func NewExporterCtrl(db *database.Database, assets *AssetControl) *ExporterCtrl

func (*ExporterCtrl) Export

func (ec *ExporterCtrl) Export(ctx context.Context, w io.Writer, cmd ExportCmd) error

type FileBlobs

type FileBlobs interface {
	WriteFile(*entities.File) error
	RemoveFile(*entities.File) error
}

type FileControl

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

func NewFileControl

func NewFileControl(db *database.Database, repo FileRepo, blobs FileBlobs) *FileControl

func (*FileControl) Delete

func (fc *FileControl) Delete(ctx context.Context, id int64) error

func (*FileControl) DeleteAllForAsset

func (fc *FileControl) DeleteAllForAsset(ctx context.Context, assetID int64) error

func (*FileControl) DeleteByPublicPath

func (fc *FileControl) DeleteByPublicPath(ctx context.Context, publicPath string) error

func (*FileControl) Get

func (fc *FileControl) Get(ctx context.Context, id int64) (*entities.File, error)

func (*FileControl) List

func (*FileControl) WriteFile

func (fc *FileControl) WriteFile(ctx context.Context, file *entities.File) (*entities.File, error)

type FileRepo

type FileRepo interface {
	Get(ctx context.Context, exec bob.Executor, id int64) (*entities.File, error)
	GetByPublicPath(ctx context.Context, exec bob.Executor, publicPath string) (*entities.File, error)
	List(ctx context.Context, exec bob.Executor, query database.ListFilesQuery) (*entities.ListPage[*entities.File], error)
	Create(ctx context.Context, exec bob.Executor, file *entities.File) (int64, error)
	Delete(ctx context.Context, exec bob.Executor, ids []int64) error
}

type GenerateLabelSheetQuery

type GenerateLabelSheetQuery struct {
	BaseURL *url.URL
	IDs     []int64
	Sheet   *entities.Sheet
}

type GetAssetQuery

type GetAssetQuery struct {
	ID               int64
	Tag              string
	IncludePurchases bool
	IncludeParts     bool
	IncludeFiles     bool
	IncludeParent    bool
	IncludeChildren  bool
}

type GetUserForCredentialsQuery

type GetUserForCredentialsQuery struct {
	Username        string
	PlaintextPasswd string
}

type ImportCmd

type ImportCmd struct {
	ImportUserID     int64
	IgnoreDuplicates bool
	Format           string
	SnipeITURL       string
	SnipeITAPIKey    string
}

type ImporterCtrl

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

func NewImporterCtrl

func NewImporterCtrl(config ImporterCtrlConfig, db *database.Database, assets *AssetControl, tags *TagControl) *ImporterCtrl

func (*ImporterCtrl) Import

func (ic *ImporterCtrl) Import(r *http.Request, cmd ImportCmd) (map[string]string, error)

type ImporterCtrlConfig added in v0.3.1

type ImporterCtrlConfig struct {
	DefaultCurrency string
}

type LabelController

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

func NewLabelController

func NewLabelController(assets *AssetControl) *LabelController

func (*LabelController) GenerateLabelSheet

func (lc *LabelController) GenerateLabelSheet(ctx context.Context, query GenerateLabelSheetQuery) ([]byte, error)

type ListAssetsQuery

type ListAssetsQuery struct {
	SearchRaw    string
	SearchFields map[string]string

	IDs []int64

	Page     int
	PageSize int

	OrderBy  string
	OrderDir string

	AssetType entities.AssetType

	IncludeParts bool
}

type ListCategoriesQuery

type ListCategoriesQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListCustomAttrsQuery

type ListCustomAttrsQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListFilesQuery

type ListFilesQuery struct {
	AssetID  int64
	Page     int
	PageSize int
}

type ListLocationsQuery

type ListLocationsQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListManufacturersQuery

type ListManufacturersQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListModelsQuery

type ListModelsQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListPositionCodesQuery

type ListPositionCodesQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListSuppliersQuery

type ListSuppliersQuery struct {
	Search   string
	Page     int
	PageSize int
}

type ListTagsQuery

type ListTagsQuery struct {
	Search   string
	InUse    *bool
	Page     int
	PageSize int
	OrderBy  string
	OrderDir string
}

type ListUsersQuery

type ListUsersQuery struct {
	Search   string
	Page     int
	PageSize int
	OrderBy  string
	OrderDir string
}

type LocalAuthRepo

type LocalAuthRepo interface {
	Get(ctx context.Context, tx bob.Executor, username string) (*auth.LocalAuthUser, error)
	Create(ctx context.Context, tx bob.Executor, user *auth.LocalAuthUser) error
	Update(ctx context.Context, tx bob.Executor, user *auth.LocalAuthUser) error
	DeleteByUsername(ctx context.Context, tx bob.Executor, username string) error
}

type LocationControl

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

func NewLocationControl

func NewLocationControl(db *database.Database, repo LocationRepo) *LocationControl

func (*LocationControl) ListLocations

func (*LocationControl) ListPositionCodes

type LocationRepo

type LocationRepo interface {
	ListLocations(ctx context.Context, exec bob.Executor, query database.ListLocationsQuery) (*entities.ListPage[*entities.Location], error)
	ListPositionCodes(ctx context.Context, exec bob.Executor, query database.ListPositionCodesQuery) (*entities.ListPage[*entities.PositionCode], error)
}

type ManufactuerCtrl

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

func NewManufactuerCtrl

func NewManufactuerCtrl(db *database.Database, repo ManufactuerRepo) *ManufactuerCtrl

func (*ManufactuerCtrl) List

type ManufactuerRepo

type ManufactuerRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListManufacturersQuery) (*entities.ListPage[*entities.Manufacturer], error)
}

type ModelCtrl

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

func NewModelCtrl

func NewModelCtrl(db *database.Database, repo ModelRepo) *ModelCtrl

func (*ModelCtrl) List

type ModelRepo

type ModelRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListModelsQuery) (*entities.ListPage[*entities.Model], error)
}

type ResetPasswordCmd

type ResetPasswordCmd struct {
	UserID          int64
	PlaintextPasswd string
}

type SupplierCtrl

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

func NewSupplierCtrl

func NewSupplierCtrl(db *database.Database, repo SupplierRepo) *SupplierCtrl

func (*SupplierCtrl) List

type SupplierRepo

type SupplierRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListSuppliersQuery) (*entities.ListPage[*entities.Supplier], error)
}

type TagControl

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

func NewTagControl

func NewTagControl(db *database.Database, algorithm string, repo TagRepo) *TagControl

func (*TagControl) CreateIfNotExists

func (tc *TagControl) CreateIfNotExists(ctx context.Context, tag string) (*entities.Tag, error)

func (*TagControl) Delete

func (tc *TagControl) Delete(ctx context.Context, tag string) error

func (*TagControl) Get

func (tc *TagControl) Get(ctx context.Context, tag string) (*entities.Tag, error)

func (*TagControl) GetNext

func (tc *TagControl) GetNext(ctx context.Context) (string, error)

func (*TagControl) List

func (*TagControl) MarkTagUnused

func (tc *TagControl) MarkTagUnused(ctx context.Context, tag string) error

type TagRepo

type TagRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListTagsQuery) (*entities.ListPage[*entities.Tag], error)
	GetUnused(ctx context.Context, exec bob.Executor) (*entities.Tag, error)
	Get(ctx context.Context, exec bob.Executor, tag string) (*entities.Tag, error)
	Create(ctx context.Context, exec bob.Executor, tag *entities.Tag) error
	MarkTagUsed(ctx context.Context, exec bob.Executor, tag string) error
	MarkTagUnused(ctx context.Context, exec bob.Executor, tag string) error
	Delete(ctx context.Context, exec bob.Executor, tag string) error
	NextSequential(ctx context.Context, exec bob.Executor) (int64, error)
}

type UpdateAssetCmd

type UpdateAssetCmd struct {
	Asset *entities.Asset
	Image *entities.File
}

type UserControl

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

func NewUserCtrl

func NewUserCtrl(db *database.Database, repo UserRepo) *UserControl

func (*UserControl) CountAdmins

func (cc *UserControl) CountAdmins(ctx context.Context) (int64, error)

func (*UserControl) Create

func (cc *UserControl) Create(ctx context.Context, user *auth.User) error

func (*UserControl) Delete

func (cc *UserControl) Delete(ctx context.Context, id int64) error

func (*UserControl) Get

func (cc *UserControl) Get(ctx context.Context, id int64) (*auth.User, error)

func (*UserControl) GetByRef

func (cc *UserControl) GetByRef(ctx context.Context, ref string) (*auth.User, error)

func (*UserControl) GetByUsername

func (cc *UserControl) GetByUsername(ctx context.Context, username string) (*auth.User, error)

func (*UserControl) List

func (*UserControl) SetUserPreferences added in v0.7.0

func (cc *UserControl) SetUserPreferences(ctx context.Context, user *auth.User) error

func (*UserControl) Update

func (cc *UserControl) Update(ctx context.Context, user *auth.User) error

type UserRepo

type UserRepo interface {
	List(ctx context.Context, exec bob.Executor, query database.ListUsersQuery) (*entities.ListPage[*auth.User], error)
	Create(ctx context.Context, exec bob.Executor, user *auth.User) error
	Update(ctx context.Context, exec bob.Executor, user *auth.User) error
	Get(ctx context.Context, exec bob.Executor, id int64) (*auth.User, error)
	GetByUsername(ctx context.Context, exec bob.Executor, username string) (*auth.User, error)
	GetByRef(ctx context.Context, exec bob.Executor, ref string) (*auth.User, error)
	CountAdmins(ctx context.Context, exec bob.Executor) (int64, error)
	Delete(ctx context.Context, exec bob.Executor, id int64) error

	UpsertPreferences(ctx context.Context, exec bob.Executor, user *auth.User) error
}

Jump to

Keyboard shortcuts

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