Documentation
¶
Index ¶
- Constants
- Variables
- func CreateDefaultTables(db *gorm.DB) error
- func CreateNumber(number string, ndigits *int) (string, error)
- func InitDB()
- func InitDb() *gorm.DB
- func InitializeDB(databaseURL string) (*gorm.DB, error)
- func RolePermissions(role Permission) []string
- type AreaUnit
- type Base
- type DataBasePostgreSQL
- type Database
- type DatabaseGen
- 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 PdmRole
- type PdmUser
- type PdmUserProjectLink
- type PdmUserRoleLink
- type PdmVendor
- type Permission
- type Project
- type ProjectState
- type ReleaseStates
- type RevisionState
- type Role
- type Search
- type SearchItem
- type SearchProject
- type SearchUser
- type TempRole
- type TempUser
- type TracebilityState
- type User
- type UserAccount
- type UserRole
- 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]" )
const DB_HOST = "127.0.0.1"
const DB_NAME = "my_db"
const DB_PASSWORD = "root"
const DB_PORT = "3306"
const DB_USERNAME = "root"
Variables ¶
var Db *gorm.DB
Functions ¶
func CreateDefaultTables ¶
CreateDefaultTables creates the default set of tables in the database.
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 InitializeDB ¶
InitializeDB initializes the database connection.
func RolePermissions ¶
func RolePermissions(role Permission) []string
role -> permissions mapping See: https://www.osohq.com/academy/role-based-access-control-rbac
Types ¶
type DataBasePostgreSQL ¶
type DataBasePostgreSQL struct {
*DatabaseGen
}
DataBasePostgreSQL struct feeds forward of generic SQL functions to PostgreSQL
func NewDataBasePostgreSQL ¶
func NewDataBasePostgreSQL() *DataBasePostgreSQL
NewDataBasePostgreSQL initializes a new PostgreSQL database
func (*DataBasePostgreSQL) StartEngine ¶
func (db *DataBasePostgreSQL) StartEngine(echo bool) error
StartEngine starts the PostgreSQL engine
type Database ¶
Database struct encapsulates the GORM DB instance.
func StartYourEngine ¶
StartYourEngine initializes the database connection.
func (*Database) CreateDefaultTables ¶
CreateDefaultTables creates default tables in the database.
type DatabaseGen ¶
type DatabaseGen struct {
DriverName string
Username string
Password string
Host string
Port int
DatabaseName string
Engine *gorm.DB
}
DatabaseGen is a generic SQL Database class
func NewDatabaseGen ¶
func NewDatabaseGen() *DatabaseGen
NewDatabaseGen initializes a new DatabaseGen
func (*DatabaseGen) CreateTable ¶
func (db *DatabaseGen) CreateTable() error
CreateTable not implemented yet
func (*DatabaseGen) DeleteTable ¶
func (db *DatabaseGen) DeleteTable() error
DeleteTable not implemented yet
func (*DatabaseGen) GetTables ¶
func (db *DatabaseGen) GetTables() error
GetTables not implemented yet
func (*DatabaseGen) MakeURL ¶
func (db *DatabaseGen) MakeURL() string
MakeURL creates a new connection URL
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 `gorm:"foreignKey:UserID"`
User PdmUser `gorm:"foreignKey:UserID"`
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
// ModelID uint `gorm:"foreignKey:ModelID"`
// Model PdmModel `gorm:"foreignKey:ModelID"`
ItemID uint `gorm:"foreignKey:ItemID"`
Item PdmItem `gorm:"foreignKey:ItemID"`
}
PdmMaterial represents the materials table
type PdmModel ¶
type PdmModel struct {
Base
ModelNumber int // Or string?
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 // For LargeBinary
UserID uint `gorm:"foreignKey:UserID"`
User PdmUser `gorm:"foreignKey:UserID"`
ItemID uint `gorm:"foreignKey:ItemID"`
Item PdmItem `gorm:"foreignKey:ItemID"`
Material PdmMaterial `gorm:"foreignKey:ModelID"`
}
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 PdmRole ¶
type PdmRole struct {
Base
RoleName string `gorm:"type:varchar(32)"`
Users []*PdmUser `gorm:"many2many:user_role_link"`
}
PdmRole represents the roles table
type PdmUser ¶
type PdmUser struct {
Base
UserName string `gorm:"type:varchar(30)"`
UserFirstName string `gorm:"type:varchar(30)"`
UserLastName string `gorm:"type:varchar(30)"`
UserFullName string
UserEmailAddress string `gorm:"not null"`
UserPhoneNumber int // Consider changing to string if phone numbers include characters
UserDepartment string // Enum type can be defined later
Roles []*PdmRole `gorm:"many2many:user_role_link"`
Projects []*PdmProject `gorm:"many2many:user_project_link"`
Items []PdmItem `gorm:"foreignKey:UserID"`
Models []PdmModel `gorm:"foreignKey:UserID"`
Documents []PdmDocument `gorm:"foreignKey:UserID"`
}
PdmUser represents the users table
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 Permission ¶
type Permission int
const ( General Permission = iota CadUser SuperUser ProjectLeader Admin )
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 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 TempUser ¶
type TempUser struct {
}
Struct for generating users Users are Aliases for roles in SQL see: https://www.postgresql.org/docs/14/sql-createuser.html
func (TempUser) AddUserToLdap ¶
func (TempUser) AddUserToSql ¶
func (TempUser) RemoveUserFromLdap ¶
Delete existing user
func (TempUser) RemoveUserFromSql ¶
Delete existing user
type TracebilityState ¶
type TracebilityState string
type User ¶
type User struct {
}
for generating users Users are Aliases for roles in SQL see: https://www.postgresql.org/docs/14/sql-createuser.html
func (User) AddUserToLdap ¶
func (User) AddUserToSql ¶
func (User) RemoveUserFromLdap ¶
Delete existing user
func (User) RemoveUserFromSql ¶
Delete existing user
type UserAccount ¶
UserAccount represents the user_accounts table.
type VolumeUnit ¶
type VolumeUnit string
type WeightUnit ¶
type WeightUnit string