Documentation
¶
Index ¶
- Constants
- Variables
- func CreateNumber(number string, ndigits *int) (string, error)
- func GetAvailableRoles() []string
- func InitDB() (*gorm.DB, error)
- type AccountStatus
- type AreaUnit
- type Base
- type Claims
- type DensityUnit
- type Document
- type FileSystem
- type Item
- type Model
- type OwnerStates
- type PdmDocument
- type PdmHistory
- type PdmItem
- type PdmManufacturer
- type PdmMaterial
- type PdmModel
- type PdmProject
- type PdmProjectItemLink
- type PdmPurchase
- type PdmUser
- type PdmUserProjectLink
- type PdmUserRoleLink
- type PdmVendor
- type Project
- type ProjectState
- type RBAC
- type ReleaseStates
- type RevisionState
- type Role
- type RoleList
- type Search
- type SearchItem
- type SearchProject
- type SearchUser
- type Session
- type TracebilityState
- type UserRepo
- func (r *UserRepo) AddUserToLdap(loginname string)
- func (r *UserRepo) ClearMustChangePassword(loginname string) error
- func (r *UserRepo) CreateUser(user *PdmUser) error
- func (r *UserRepo) GetAllUsers() ([]PdmUser, error)
- func (r *UserRepo) LoadUser(loginname string) (*PdmUser, error)
- func (r *UserRepo) LoadUserByID(id uint) (*PdmUser, error)
- func (r *UserRepo) LoadUserByLoginName(loginName string) (*PdmUser, error)
- func (r *UserRepo) NormalizeAllUsers() error
- func (r *UserRepo) NormalizeAllUsersVerbose() (changedCount, totalCount int, err error)
- func (r *UserRepo) NormalizeUserRoles(loginname string) error
- func (r *UserRepo) NormalizeUserRolesVerbose(loginname string) (bool, error)
- func (r *UserRepo) RemoveUserFromLdap(user_id int, loginname string)
- func (r *UserRepo) UpdatePassword(loginname, hash string) error
- func (r *UserRepo) UpdatePhotoPath(userID uint, photoPath string) error
- func (r *UserRepo) UpdateUser(user *PdmUser) error
- type VolumeUnit
- type WeightUnit
Constants ¶
const ( New ProjectState = "New" Upcoming ProjectState = "Upcoming" Pending ProjectState = "Pending" NotStarted ProjectState = "Not Started" Draft ProjectState = "Draft" Active ProjectState = "Active" Priority ProjectState = "Priority" Canceld ProjectState = "Canceled" Onhold ProjectState = "On-Hold" Archived ProjectState = "Archived" Concept RevisionState = "Concept" Underreview RevisionState = "Under Review" Released RevisionState = "Released" Inwork RevisionState = "In-Work" Depreciated RevisionState = "Depreciated" Lot TracebilityState = "Lot" LotSerial TracebilityState = "Lot and Serial" Serial TracebilityState = "Serial" NotTaced TracebilityState = "Not-Traced" D_gmm3 DensityUnit = "Gram / mm^3" D_gcm3 DensityUnit = "Gram / cm^3" D_kgm3 DensityUnit = "Kilo Gram / m^3" D_tonnem3 DensityUnit = "Tonne / m^3" D_metrictonm3 DensityUnit = "Metric Ton / m^3" // equal to tonne D_poundft3 DensityUnit = "Pound / Ft^3" D_poundinch3 DensityUnit = "Pound / inch^3" V_mm3 VolumeUnit = "Cubic mm [mm^3]" V_cm3 VolumeUnit = "Cubic cm [cm^3]" V_m3 VolumeUnit = "Cubic m [m^3]" V_litre VolumeUnit = "Litre" V_ft3 VolumeUnit = "Cubic ft [Ft^3]" V_inch3 VolumeUnit = "Cubic inch [Inch^3]" W_g WeightUnit = "Gram [g]" W_kg WeightUnit = "Kilo Gram [kg]" W_tonne WeightUnit = "Tonne [t]" W_metricton WeightUnit = "Metric Ton" // equal to tonne W_pound WeightUnit = "Pound [p]" W_slug WeightUnit = "Slug" A_mm2 AreaUnit = "Square mm [mm^2]" A_cm2 AreaUnit = "Square cm [cm^2]" A_m2 AreaUnit = "Square m [m^2]" A_ft2 AreaUnit = "Square ft [Ft^2]" A_inch2 AreaUnit = "Square inch [Inch^2]" )
Variables ¶
var ErrUserNotFound = errors.New("user not found")
var Sessions = map[string]Session{}
Functions ¶
func CreateNumber ¶
Create new Project number number is only added when it has a value. CreateNumber generates a new project number based on the last current number. number: Last current number as a string, including leading zeros. ndigits: Number of digits for the new number length. If -1, the length is just the length of the number.
func GetAvailableRoles ¶ added in v0.1.3
func GetAvailableRoles() []string
GetAvailableRoles returns a list of roles
Types ¶
type AccountStatus ¶ added in v0.1.3
type AccountStatus string
const ( StatusActive AccountStatus = "active" StatusDisabled AccountStatus = "disabled" StatusLocked AccountStatus = "locked" StatusPending AccountStatus = "pending" StatusSuspended AccountStatus = "suspended" StatusExpired AccountStatus = "expired" StatusDeleted AccountStatus = "deleted" StatusInvited AccountStatus = "invited" )
type Base ¶
type Base struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
Base struct to embed in other models
type Claims ¶ added in v0.1.3
type Claims struct {
Role string `json:"role"`
jwt.StandardClaims
}
type DensityUnit ¶
type DensityUnit string
type FileSystem ¶
type FileSystem struct{}
File System related Class
func (*FileSystem) Init ¶
func (fs *FileSystem) Init()
type Item ¶
type Item struct {
gorm.Model
ID uint `gorm:"primaryKey"`
ItemName string `gorm:"size:100"`
// number int
Project string
Path string
Name string
Description string
FullDescription string
}
Item represents the items table.
type OwnerStates ¶
type OwnerStates struct {
}
Item / Model / Document Ownership states
func (OwnerStates) CheckInCheckOut ¶
func (o OwnerStates) CheckInCheckOut()
Check in Items, Models, Documents
type PdmDocument ¶
type PdmDocument struct {
Base
DocumentNumber int // Or string?
DocumentName string `gorm:"type:varchar(32)"`
DocumentDescription string `gorm:"type:varchar(32)"`
DocumentFullDescription string
DocumentFilename string `gorm:"type:varchar(253);not null"`
DocumentExt string `gorm:"type:varchar(253);not null"`
UserID uint `gorm:"foreignKey:UserID"`
User PdmUser `gorm:"foreignKey:UserID"`
ItemID uint `gorm:"foreignKey:ItemID"`
Item PdmItem `gorm:"foreignKey:ItemID"`
}
PdmDocument represents the documents table
type PdmHistory ¶
type PdmHistory struct {
Base
HistoryDateCreated *time.Time
HistoryCreatedBy string
HistoryDateLastEdit *time.Time
HistoryLastEditBy string
HistoryCheckedOutBy string
HistoryRevisionState string // Enum can be defined later
HistoryRevisionNumber int
HistoryStoredNumber int
}
PdmHistory represents the history table
type PdmItem ¶
type PdmItem struct {
Base
ItemNumber string `gorm:"type:varchar(16)"`
ItemName string `gorm:"type:varchar(32)"`
ItemDescription string `gorm:"type:varchar(32)"`
ItemFullDescription string
ItemNumberLinkedFiles int
ItemPath string `gorm:"not null"`
ItemPreview []byte // For LargeBinary
UserID uint
User PdmUser
ProjectID uint `gorm:"foreignKey:ProjectID"`
Models []PdmModel `gorm:"foreignKey:ItemID"`
Documents []PdmDocument `gorm:"foreignKey:ItemID"`
}
PdmItem represents the items table
type PdmManufacturer ¶
type PdmManufacturer struct {
Base
ManufacturerName string `gorm:"type:varchar(32)"`
PurchasingID uint `gorm:"foreignKey:PurchasingID"`
Purchasing PdmPurchase `gorm:"foreignKey:PurchasingID"`
}
PdmManufacturer represents the manufacturers table
type PdmMaterial ¶
type PdmMaterial struct {
Base
MaterialName string `gorm:"type:varchar(32)"`
MaterialFinish string `gorm:"type:varchar(32)"`
MaterialDensity float64
MaterialDensityUnit string // Enum can be defined later
MaterialVolume float64
MaterialVolumeUnit string // Enum can be defined later
MaterialWeight float64
MaterialWeightUnit string // Enum can be defined later
MaterialSurfaceArea float64
MaterialSurfaceAreaUnit string // Enum can be defined later
}
PdmMaterial represents the materials table
type PdmModel ¶
type PdmModel struct {
Base
ModelNumber int
ModelName string `gorm:"type:varchar(32)"`
ModelDescription string `gorm:"type:varchar(32)"`
ModelFullDescription string
ModelFilename string `gorm:"type:varchar(253);not null"`
ModelExt string `gorm:"type:varchar(253);not null"`
ModelPreview []byte
UserID uint
User PdmUser
ItemID uint
Item PdmItem
MaterialID uint
Material PdmMaterial `gorm:"foreignKey:MaterialID;references:ID"`
}
PdmModel represents the models table
type PdmProject ¶
type PdmProject struct {
Base
ProjectNumber string `gorm:"type:varchar(16);not null"`
ProjectName string `gorm:"type:varchar(32)"`
ProjectStatus string // Enum type can be defined later
ProjectDateStart *time.Time
ProjectDateFinish *time.Time
ProjectPath string
Users []*PdmUser `gorm:"many2many:user_project_link"`
}
PdmProject represents the projects table
type PdmProjectItemLink ¶
type PdmProjectItemLink struct {
ProjectID uint `gorm:"primaryKey;autoIncrement:false"`
ItemID uint `gorm:"primaryKey;autoIncrement:false"`
}
PdmProjectItemLink is the association table for projects and items
type PdmPurchase ¶
type PdmPurchase struct {
Base
PurchasingSource bool
PurchasingTraceability string // Enum can be defined later
ItemID uint `gorm:"foreignKey:ItemID"`
Item PdmItem `gorm:"foreignKey:ItemID"`
ManufacturerID uint `gorm:"foreignKey:ManufacturerID"`
Manufacturers []PdmManufacturer `gorm:"foreignKey:ManufacturerID"`
VendorID uint `gorm:"foreignKey:VendorID"`
Vendors []PdmVendor `gorm:"foreignKey:VendorID"`
}
PdmPurchase represents the purchasing table
type PdmUser ¶
type PdmUser struct {
Base
LoginName string `gorm:"column:login_name;type:varchar(30);not null;uniqueIndex"`
FullName string `gorm:"type:varchar(61)"`
PasswordHash string `gorm:"type:varchar(60);not null"`
MustChangePassword bool `gorm:"default:true"`
FirstName string `gorm:"type:varchar(30)"`
LastName string `gorm:"type:varchar(30)"`
DateOfBirth time.Time `gorm:"type:date"`
Sex string `gorm:"type:varchar(10)"` // "male", "female", or "x"
EmailAddress string `gorm:"type:varchar(255);not null;uniqueIndex"`
PhoneNumber string `gorm:"type:varchar(20)"`
Department string `gorm:"type:varchar(30)"`
PhotoPath string `gorm:"type:varchar(255)"`
AccountStatus string `gorm:"type:varchar(20);default:'active'"`
Roles pq.StringArray `gorm:"type:text[]"`
}
func (*PdmUser) HasAllRoles ¶ added in v0.1.3
func (*PdmUser) HasAnyPermission ¶ added in v0.1.3
HasAnyPermission checks if the user has at least one of the given permissions.
func (*PdmUser) HasAnyRole ¶ added in v0.1.3
Check whether user has all the roles
func (*PdmUser) HasPermission ¶ added in v0.1.3
HasPermission checks if the user has the given RBAC permission.
type PdmUserProjectLink ¶
type PdmUserProjectLink struct {
UserID uint `gorm:"primaryKey;autoIncrement:false"`
ProjectID uint `gorm:"primaryKey;autoIncrement:false"`
}
PdmUserProjectLink is the association table for users and projects
type PdmUserRoleLink ¶
type PdmUserRoleLink struct {
UserID uint `gorm:"primaryKey;autoIncrement:false"`
RoleID uint `gorm:"primaryKey;autoIncrement:false"`
}
PdmUserRoleLink is the association table for users and roles
type PdmVendor ¶
type PdmVendor struct {
Base
VendorName string `gorm:"type:varchar(32)"`
VPurchasingID uint `gorm:"foreignKey:VPurchasingID"`
VPurchasing PdmPurchase `gorm:"foreignKey:VPurchasingID"`
}
PdmVendor represents the vendors table
type Project ¶
type Project struct {
gorm.Model
ID uint `gorm:"primaryKey"`
ProjectName string `gorm:"size:100"`
// contains filtered or unexported fields
}
Project represents the projects table.
func NewProject ¶
Create new project
func (*Project) RemoveUserFromProject ¶
func (p *Project) RemoveUserFromProject()
Remove user from project
type ProjectState ¶
type ProjectState string
type RBAC ¶ added in v0.1.3
type RBAC string
const ( CheckIn RBAC = "Check-In" CheckOut RBAC = "Check-Out" CreateDocument RBAC = "Create Document" CreateItem RBAC = "Create Item" CreateModel RBAC = "Create Model" DeleteDocument RBAC = "Delete Document" DeleteItem RBAC = "Delete Item" DeleteModel RBAC = "Delete Model" CreateProject RBAC = "Create Project" AddUserToProject RBAC = "Add User to Project" RemoveUserFromProject RBAC = "Remove User from Project" CreateUser RBAC = "Create User" DeleteUser RBAC = "Delete User" CreateDatabase RBAC = "Create Database" ReadDocuments RBAC = "Read Documents" ReadItems RBAC = "Read Items" ReadModels RBAC = "Read Models" )
type ReleaseStates ¶
type ReleaseStates struct {
}
Item / Model /Document release states struct
func (ReleaseStates) ChangeReleaseState ¶
func (r ReleaseStates) ChangeReleaseState()
new Item, Model, Document
func (ReleaseStates) Depreciated ¶
func (r ReleaseStates) Depreciated()
Check in Items, Models, Documents
func (ReleaseStates) NotForNew ¶
func (r ReleaseStates) NotForNew()
Check in Items, Models, Documents
type RevisionState ¶
type RevisionState string
type Search ¶
type Search struct {
}
Search https://docs.sqlalchemy.org/en/14/orm/session_basics.html
func (Search) SearchDescription ¶
Search on description
func (Search) SearchSomething_else ¶
Search on something else
type SearchItem ¶
type SearchItem struct {
}
Search for projects
func NewSearchItem ¶ added in v0.1.3
func NewSearchItem() *SearchItem
func (SearchItem) ItemDescription ¶ added in v0.1.3
func (s SearchItem) ItemDescription(description string)
Search on project description
func (SearchItem) ItemNumber ¶ added in v0.1.3
func (s SearchItem) ItemNumber(user_number string)
Search on project number
type SearchProject ¶
type SearchProject struct {
}
Search for projects
func NewSearchProject ¶ added in v0.1.3
func NewSearchProject() *SearchProject
func (SearchProject) ProjectDescription ¶ added in v0.1.3
func (s SearchProject) ProjectDescription(description string)
Search on project description
func (SearchProject) ProjectNumber ¶ added in v0.1.3
func (s SearchProject) ProjectNumber(user_number string)
Search on project number
type SearchUser ¶
type SearchUser struct {
}
Search for projects
func NewSearchUser ¶ added in v0.1.3
func NewSearchUser() *SearchUser
func (SearchUser) UserFirstFame ¶ added in v0.1.3
func (s SearchUser) UserFirstFame(user_first_name string)
Search on user first name
func (SearchUser) UserLastName ¶ added in v0.1.3
func (s SearchUser) UserLastName(user_last_name string)
Search on user last name
func (SearchUser) UserName ¶ added in v0.1.3
func (s SearchUser) UserName(user_name string)
Search on user name
func (SearchUser) UserNumber ¶ added in v0.1.3
func (s SearchUser) UserNumber(user_number string)
Search on user number
func (SearchUser) UserRole ¶ added in v0.1.3
func (s SearchUser) UserRole(user_role string)
Search on user role
type TracebilityState ¶
type TracebilityState string
type UserRepo ¶ added in v0.1.3
Ease of handling
func (*UserRepo) AddUserToLdap ¶ added in v0.1.3
func (*UserRepo) ClearMustChangePassword ¶ added in v0.1.3
Resets the MustChangePassword flag to false
func (*UserRepo) CreateUser ¶ added in v0.1.3
func (*UserRepo) GetAllUsers ¶ added in v0.1.3
func (*UserRepo) LoadUserByID ¶ added in v0.1.3
LoadUser search by ID on user name.
func (*UserRepo) LoadUserByLoginName ¶ added in v0.1.3
func (*UserRepo) NormalizeAllUsers ¶ added in v0.1.3
NormalizeAllUsers walks over all users and normalizes their roles
func (*UserRepo) NormalizeAllUsersVerbose ¶ added in v0.1.3
NormalizeAllUsersVerbose runs over all users and reports counts
func (*UserRepo) NormalizeUserRoles ¶ added in v0.1.3
NormalizeUserRoles updates the roles on a user to match the canonical lowercase Role constants
func (*UserRepo) NormalizeUserRolesVerbose ¶ added in v0.1.3
NormalizeUserRolesVerbose updates and reports if any roles were changed
func (*UserRepo) RemoveUserFromLdap ¶ added in v0.1.3
Delete existing user
func (*UserRepo) UpdatePassword ¶ added in v0.1.3
Renames password and also sets the MustChangePassword flag to false
func (*UserRepo) UpdatePhotoPath ¶ added in v0.1.3
UpdatePhotoPath updates the PhotoPath of a user by their ID.
func (*UserRepo) UpdateUser ¶ added in v0.1.3
UpdateUser saves the updated user record into the database. It overwrites the existing user entry based on its primary key.
type VolumeUnit ¶
type VolumeUnit string
type WeightUnit ¶
type WeightUnit string