models

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Public    = "Public"    // Public is visible for everyone including nont registered visitors
	Protected = "Protected" // Content is available for registered users
	Private   = "Private"   // Content is available for the owner and users the product or project is shared with.
)

This contants describe the visibility of proucts and projects

View Source
const (
	SupportClients = "support_clients"
	ClientUI       = "client_ui"
	ProjectUI      = "project_ui"
	Requires3D     = "requires_3d"
	HasTrial       = "has_trial"
	IsFree         = "is_free"
)
View Source
const (
	BaseAssetPath = "base_asset_path"
)
View Source
const (
	TwoStepsVerif = "two_steps_verif"
)

Variables

View Source
var ErrAssetRefNotInitialised = errors.New("Asset references not initialised")
View Source
var ErrInvalidAssetsID = "Invalid assets uuid"
View Source
var ErrInvalidSettingsID = "Invalid settings uuid"
View Source
var ErrProductDetailsNotInitialised = "Details map not initialised"
View Source
var ErrSettingNotInitialised = "Settings not initialised"

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID      uuid.UUID `json:"id" validate:"required"`
	DataMap DataMap   `json:"datamap" validate:"required"`
}

type DataMap added in v0.0.7

type DataMap map[string]interface{}

Assets structure contains the identification of all user related documents images.

type ModelFunctionsCommon added in v0.0.10

type ModelFunctionsCommon interface {
	NewAsset(references DataMap) (*Asset, error)
	NewUser(
		name string,
		email string,
		password []byte,
		settingsID uuid.UUID,
		assetsID uuid.UUID) (*User, error)
	NewProduct(name string, detailsID *uuid.UUID, assetsID *uuid.UUID) (*Product, error)
	NewProject(productID *uuid.UUID, detailsID *uuid.UUID, assetsID *uuid.UUID) (*Project, error)
	GetFilePath(asset *Asset, typeString string, defaultPath string) string
	SetFilePath(asset *Asset, typeString string, extension string) error
	GetField(asset *Asset, typeString string, defaultURL string) interface{}
	SetField(asset *Asset, typeString string, field interface{})
	ClearAsset(asset *Asset, typeString string) error
}

type Privilege

type Privilege struct {
	ID          int    `validation:"required"`
	Name        string `validation:"required"`
	Description string `validation:"required"`
}

type Privileges

type Privileges []*Privilege

func (Privileges) IsOwnerPrivilege added in v0.0.7

func (l Privileges) IsOwnerPrivilege(privilege int) bool

func (Privileges) IsPartnerPrivilege added in v0.0.7

func (l Privileges) IsPartnerPrivilege(privilege int) bool

func (Privileges) IsValidPrivilege

func (l Privileges) IsValidPrivilege(privilege int) bool

type Product

type Product struct {
	ID        uuid.UUID `validation:"required"`
	Name      string    `validation:"required"`
	AssetsID  uuid.UUID `validation:"required"`
	DetailsID uuid.UUID `validation:"required"`
}

type ProductData added in v0.0.9

type ProductData struct {
	ID      uuid.UUID `json:"id" validate:"required"`
	Name    string    `json:"name" validate:"required"`
	Assets  *Asset    `json:"assets" validate:"required"`
	Details *Asset    `json:"details" validate:"required"`
}

type ProductUser added in v0.0.9

type ProductUser struct {
	UserData  UserData
	Privilege int
}

type ProductUserIDs added in v0.0.9

type ProductUserIDs struct {
	UserMap     map[uuid.UUID]int
	UserIDArray []uuid.UUID
}

type Project

type Project struct {
	ID        uuid.UUID `validation:"required"`
	ProductID uuid.UUID `validation:"required"`
	AssetsID  uuid.UUID `validation:"required"`
	DetailsID uuid.UUID `validation:"required"`
}

type ProjectData added in v0.0.9

type ProjectData struct {
	ID        uuid.UUID `json:"id" validate:"required"`
	ProductID uuid.UUID `json:"product-id" validate:"required"`
	Assets    *Asset    `json:"assets" validate:"required"`
	Details   *Asset    `json:"details" validate:"required"`
}

type ProjectUserIDs added in v0.0.9

type ProjectUserIDs struct {
	UserMap     map[uuid.UUID]int
	UserIDArray []uuid.UUID
}

type ProjectViewer added in v0.0.21

type ProjectViewer struct {
	UserID    uuid.UUID `json:"user_id" validate:"required"`
	ViewerID  uuid.UUID `json:"viewer_id" validate:"required"`
	ProjectID uuid.UUID `json:"project_id" validate:"required"`
	IsOwner   bool      `json:"is_owner" validate:"required"`
}

type RepoFunctions added in v0.0.10

type RepoFunctions struct {
	UUIDImpl UUIDCommon
}
var ModelFunctions *RepoFunctions

func (*RepoFunctions) ClearAsset added in v0.0.10

func (f *RepoFunctions) ClearAsset(asset *Asset, typeString string) error

func (*RepoFunctions) GetField added in v0.0.10

func (f *RepoFunctions) GetField(asset *Asset, typeString string, defaultValue string) interface{}

func (*RepoFunctions) GetFilePath added in v0.0.10

func (f *RepoFunctions) GetFilePath(asset *Asset, typeString string, defaultPath string) string

func (*RepoFunctions) NewAsset added in v0.0.10

func (f *RepoFunctions) NewAsset(references DataMap) (*Asset, error)

func (*RepoFunctions) NewProduct added in v0.0.10

func (f *RepoFunctions) NewProduct(name string, detailsID *uuid.UUID, assetsID *uuid.UUID) (*Product, error)

NewProduct creates a new product instance where details describe the configuration of the product and references contain all asset references.

func (*RepoFunctions) NewProject added in v0.0.10

func (f *RepoFunctions) NewProject(productID *uuid.UUID, detailsID *uuid.UUID, assetsID *uuid.UUID) (*Project, error)

func (*RepoFunctions) NewUser added in v0.0.10

func (f *RepoFunctions) NewUser(
	name string,
	email string,
	password []byte,
	settingsID uuid.UUID,
	assetsID uuid.UUID) (*User, error)

func (*RepoFunctions) SetField added in v0.0.10

func (f *RepoFunctions) SetField(asset *Asset, typeString string, field interface{})

func (*RepoFunctions) SetFilePath added in v0.0.10

func (f *RepoFunctions) SetFilePath(asset *Asset, typeString string, extension string) error

type RepoUUID added in v0.0.10

type RepoUUID struct {
}

func (*RepoUUID) NewUUID added in v0.0.10

func (*RepoUUID) NewUUID() (uuid.UUID, error)

NewUUID is a wrapper to allow mocking

type UUIDCommon added in v0.0.10

type UUIDCommon interface {
	NewUUID() (uuid.UUID, error)
}

type UUIDImplMock added in v0.0.7

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

UUIDImplMock overwrites the default github uuid library implementation.

var UUIDImpl *UUIDImplMock

func (*UUIDImplMock) NewUUID added in v0.0.7

func (i *UUIDImplMock) NewUUID() (uuid.UUID, error)

type User

type User struct {
	ID         uuid.UUID
	Name       string
	Email      string
	Password   []byte
	SettingsID uuid.UUID
	AssetsID   uuid.UUID
}

User defines the user structures. Each user must have an associated settings entry.

type UserData added in v0.0.9

type UserData struct {
	ID       uuid.UUID `json:"id" validate:"required"`
	Name     string    `json:"username" validate:"required"`
	Email    string    `json:"email" validate:"required"`
	Password []byte    `json:"password" validate:"required"`
	Settings *Asset    `json:"settings" validate:"required"`
	Assets   *Asset    `json:"assets" validate:"required"`
}

type UserProduct added in v0.0.9

type UserProduct struct {
	ProductData ProductData
	Privilege   int
}

type UserProductIDs added in v0.0.9

type UserProductIDs struct {
	ProductMap     map[uuid.UUID]int
	ProductIDArray []uuid.UUID
}

type UserProject added in v0.0.9

type UserProject struct {
	ProjectData *ProjectData
	Privilege   int
}

type UserProjectIDs added in v0.0.9

type UserProjectIDs struct {
	ProjectMap     map[uuid.UUID]int
	ProjectIDArray []uuid.UUID
}

type ViewUsers added in v0.0.9

type ViewUsers struct {
	OwnerID   uuid.UUID
	UsersList []uuid.UUID
}

type Viewer added in v0.0.9

type Viewer struct {
	IsOwner   bool
	ViewerID  uuid.UUID
	ProjectID uuid.UUID
}

type ViewersList added in v0.0.9

type ViewersList []Viewer

Viewers describes a set of project data. Each set has a single viewer ID. Whichever user possese this ID can view the data with this ID. The set of project data has a single owner user. This structure contains the owner and the list of users who can view the data.

Jump to

Keyboard shortcuts

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