Documentation ¶
Index ¶
- Constants
- type Category
- type Link
- type LinkDTO
- type LinkRetrievalFn
- type LoginToken
- type LoginTokenDTO
- type PaginationInfo
- type Part
- type PartAttachment
- type PartAttachmentDTO
- type PartDTO
- type PermissionClaims
- type Search
- type StorageCategory
- type StorageCategoryDTO
- type StorageLocation
- type StorageLocationDTO
- type User
- type UserDTO
Constants ¶
const ( // TargetTypePart is the target type identifier for linking to parts TargetTypePart = "part" TargetTypePartCategory = "part.category" TargetTypePartAttachment = "part.attachment" TargetTypeStorage = "storage" TargetTypeStorageCategory = "storage.category" TargetTypeStorageImage = "storage.image" TargetTypeUnknown = "unknown" // Unsupported or not yet implemented link types )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct { InternalID int `db:"id" json:"-"` InternalParentID int `db:"parent_id" json:"-"` Name string `json:"name" db:"name"` Path string `json:"path" db:"path"` }
Category is the representation of a PartKeeper category
type Link ¶
type Link struct { Link string `db:"link"` PartID *int `db:"partID"` PartCategoryID *int `db:"partCategoryID"` PartAttachmentID *int `db:"partAttachmentID"` StorageID *int `db:"storageID"` StorageCategoryID *int `db:"storageCategoryID"` StorageImageID *int `db:"storageImageID"` AutoGenerated bool `db:"auto_generated"` CreatedAt time.Time `db:"createdAt"` }
Link contains the URL for part-lookup (Table: mate_links)
func (*Link) GetTargetType ¶
GetTargetType returns the target type string matching for this link
type LinkDTO ¶
type LinkDTO struct { // Link ID Link string `json:"link"` // Type of entity we are targeting (currently only "part") TargetType string `json:"targetType"` // ID of the target to link to - this has to be another link ID since we do not disclose the internal IDs of // entities. // When searching, links will be auto-generated for every single result (if no link exists) Target string `json:"target,omitempty"` // Was the link auto-generated? AutoGenerated bool `json:"autoGenerated"` // When was the link created? CreatedAt time.Time `json:"createdAt,omitempty"` }
type LinkRetrievalFn ¶
type LoginToken ¶
type LoginToken struct { Token string `db:"token"` Username string `db:"username"` ExpiresAt sql.NullTime `db:"expiresAt"` SessionLengthSeconds uint64 `db:"sessionLength"` }
LoginToken represents a token that can be used instead of login credentials to log a user in
func (*LoginToken) ToDTO ¶
func (t *LoginToken) ToDTO() LoginTokenDTO
ToDTO converts the LoginToken to its DTO representation
type LoginTokenDTO ¶
type LoginTokenDTO struct { Token string `json:"token"` Username string `json:"username"` ExpiresAt *int64 `json:"expiresAt,omitempty"` SessionLengthSeconds uint64 `json:"sessionLength"` }
func (*LoginTokenDTO) ToLoginToken ¶
func (t *LoginTokenDTO) ToLoginToken() LoginToken
ToLoginToken converts the DTO to a login token
type PaginationInfo ¶
type Part ¶
type Part struct { ID int `db:"id"` Link sql.NullString `db:"link"` Name string `db:"name"` Description string `db:"description"` Comment string `db:"comment"` CategoryID int `db:"category_id"` StorageLocationID int `db:"storageLocation_id"` Condition string `db:"partCondition"` StockLevel int `db:"stockLevel"` MinStockLevel int `db:"minStockLevel"` Status string `db:"status"` NeedsReview bool `db:"needsReview"` LowStock bool `db:"lowStock"` ImageID sql.NullInt64 `db:"image_id"` // Internal ID of the attachment used as image for this part ImageLink sql.NullString `db:"image_link"` // Link pointing to the image used for this part Storage *StorageLocation `db:"-"` NumAttachments int `db:"num_attachments"` }
Part represents the Struct for Part/Item Queries
type PartAttachment ¶
type PartAttachment struct { BaseDir string // Base directory where the attachments are stored Link sql.NullString `db:"link"` InternalID int `db:"id"` PartID int `db:"part_id"` Type string `db:"type"` FileName string `db:"filename"` OriginalName string `db:"originalname"` MimeType string `db:"mimetype"` Size int `db:"size"` Extension string `db:"extension"` Description sql.NullString `db:"description"` IsImage sql.NullBool `db:"isImage"` }
PartAttachment is the Struct to identify and modify Attachment-Data
func (*PartAttachment) GetExtension ¶
func (a *PartAttachment) GetExtension() string
func (*PartAttachment) IsImageFile ¶
func (a *PartAttachment) IsImageFile() bool
func (*PartAttachment) StorageLocation ¶
func (a *PartAttachment) StorageLocation() string
func (*PartAttachment) ThumbnailLocation ¶
func (a *PartAttachment) ThumbnailLocation() string
func (*PartAttachment) ToDTO ¶
func (a *PartAttachment) ToDTO() PartAttachmentDTO
type PartAttachmentDTO ¶
type PartDTO ¶
type PartDTO struct { Link string `json:"id"` // The link (external ID) of the part Name string `json:"name"` Description string `json:"description"` Comment string `json:"comment"` Condition string `json:"condition"` StockLevel int `json:"stockLevel"` MinStockLevel int `json:"minStockLevel"` Status string `json:"status"` NeedsReview bool `json:"needsReview"` LowStock bool `json:"lowStock"` ImageLink string `json:"image"` // The link (external ID) of the "cover image" for this part Storage *StorageLocationDTO `json:"storage"` NumAttachments int `json:"attachmentCount"` }
PartDTO is the data transfer object for the Part database model
type PermissionClaims ¶
type PermissionClaims struct { jwt.RegisteredClaims Permissions []string `json:"perm,omitempty"` }
PermissionClaims is a JWT claim struct that has an added permissions array
type Search ¶
type Search struct { PaginationInfo Term string `json:"term"` StorageLocationLink string `json:"storage"` }
type StorageCategory ¶
type StorageCategory struct { ID int `db:"category_id"` Link sql.NullString `db:"category_link"` Name string `db:"category_name"` Description string `db:"category_description"` Path string `db:"category_path"` }
A StorageCategory describes the category a storage location is located in
func (*StorageCategory) ToDTO ¶
func (c *StorageCategory) ToDTO() *StorageCategoryDTO
ToDTO converts the storage category into its DTO
type StorageCategoryDTO ¶
type StorageCategoryDTO struct { Name string `json:"name"` Description string `json:"description,omitempty"` Path string `json:"path,omitempty"` }
StorageCategoryDTO is the data transfer object for a storage category
type StorageLocation ¶
type StorageLocation struct { ID int `db:"id"` Link sql.NullString `db:"link"` Name string `db:"name"` StorageCategory ImageID sql.NullInt64 `db:"image_id"` // Internal ID of the attachment used as image for this location ImageLink sql.NullString `db:"image_link"` // Link pointing to the image used for this location NumParts uint `db:"parts_contained"` }
StorageLocation represents a single storage location for parts
func (*StorageLocation) ToDTO ¶
func (s *StorageLocation) ToDTO() *StorageLocationDTO
ToDTO converts the storage location to its DTO representation
A pointer is returned in this case since a storage location may be nil
type StorageLocationDTO ¶
type StorageLocationDTO struct { Link string `json:"id"` Name string `json:"name"` ImageLink string `json:"image,omitempty"` Category StorageCategoryDTO `json:"category,omitempty"` NumParts uint `json:"partsContained"` }
StorageLocationDTO is the data transfer object for a storage location
type User ¶
type User struct { Username string `db:"name"` PasswordHash string `db:"password_hash"` // Swordfish RawPermissions string `db:"permissions"` // contains filtered or unexported fields }
User is the Struct to identify the User (Table: mate_users)
func (*User) Can ¶
Can checks if the user can execute an operation requiring all of the given permissions
func (*User) CheckPassword ¶
CheckPassword takes a given password and checks if the password has matches that input
func (*User) Permissions ¶
Permissions returns the decoded permission slice
type UserDTO ¶
type UserDTO struct { Username string `json:"name"` Password string `json:"password,omitempty"` // The password will only sent to the API when creating a user Permissions []string `json:"permissions"` }
UserDTO represents a user in the JSON API
func (*UserDTO) ToUser ¶
ToUser tries to convert the DTO to the database user object - optionally also setting the password
func (*UserDTO) Validate ¶
Validate checks if the data in the user DTO is valid and returns an error if not
func (*UserDTO) ValidatePermissions ¶
ValidatePermissions checks if the provided user DTO's permissions are valid for storing permissions
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package permission collects constants for the permissions available in PartMAtE
|
Package permission collects constants for the permissions available in PartMAtE |