56 lines
2.2 KiB
Go
56 lines
2.2 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
type Profile struct {
|
|
ID string `gorm:"type:string;primary_key;" json:"id"`
|
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
|
Version int `gorm:"default:0" json:"version"`
|
|
First_Name *string `gorm:"column:first_name" json:"first_name"`
|
|
Last_Name *string `gorm:"column:last_name" json:"last_name"`
|
|
User_Name string `gorm:"column:user_name" json:"user_name"`
|
|
Email string `gorm:"column:email" json:"email"`
|
|
Password string `gorm:"column:password" json:"password"`
|
|
Enabled bool `gorm:"column:enabled" json:"enabled"`
|
|
|
|
Assignments []Assignment `gorm:"foreignKey:ProfileID" json:"assignments"`
|
|
Tokens []Token `gorm:"foreignKey:ProfileID" json:"tokens"`
|
|
}
|
|
|
|
func (profile *Profile) TableName() string {
|
|
return "profile"
|
|
}
|
|
|
|
func (profile *Profile) GetFullName() string {
|
|
full_name := ""
|
|
if profile.First_Name != nil {
|
|
full_name += *profile.First_Name
|
|
}
|
|
if profile.Last_Name != nil {
|
|
full_name += " "
|
|
full_name += *profile.Last_Name
|
|
}
|
|
return full_name
|
|
}
|
|
|
|
type ProfileDTO_ struct {
|
|
ID string `json:"id" binding:"required"`
|
|
CreatedAt time.Time `json:"created_date" binding:"required"`
|
|
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
|
DeletedAt *time.Time `json:"deleted_date" binding:"omitempty"`
|
|
Version int `json:"version" binding:"required"`
|
|
First_Name *string `json:"first_name" binding:"required"`
|
|
Last_Name *string `json:"last_name" binding:"required"`
|
|
User_Name string `json:"user_name" binding:"required"`
|
|
Email string `json:"email" binding:"required"`
|
|
Password string `json:"password" binding:"required"`
|
|
Enabled bool `json:"enabled" binding:"required"`
|
|
}
|
|
|
|
type LoginInput struct {
|
|
Email string `json:"email" binding:"required"`
|
|
Password string `json:"password" binding:"required"`
|
|
}
|