package model import ( "time" "github.com/shopspring/decimal" ) const ( USER_TYPE_ENT int16 = iota USER_TYPE_SUP USER_TYPE_OPS ) type ManagementAccountCreationForm struct { Id *string Username string Name string Contact *string Phone *string Type int16 `json:"type"` Enabled bool Expires Date } func (m ManagementAccountCreationForm) IntoUser() *User { return &User{ Id: *m.Id, Username: m.Username, Password: "", ResetNeeded: false, UserType: m.Type, Enabled: m.Enabled, CreatedAt: nil, } } func (m ManagementAccountCreationForm) IntoUserDetail() *UserDetail { return &UserDetail{ Id: *m.Id, Name: &m.Name, Abbr: nil, Region: nil, Address: nil, Contact: m.Contact, Phone: m.Phone, UnitServiceFee: decimal.Zero, ServiceExpiration: m.Expires, CreatedAt: time.Now(), CreatedBy: nil, LastModifiedAt: time.Now(), LastModifiedBy: nil, DeletedAt: nil, DeletedBy: nil, } } type UserModificationForm struct { Name string Region *string Address *string Contact *string Phone *string UnitServiceFee *decimal.Decimal } type User struct { Id string Username string Password string ResetNeeded bool UserType int16 `db:"type"` Enabled bool CreatedAt *time.Time } type UserDetail struct { Id string Name *string Abbr *string Region *string Address *string Contact *string Phone *string UnitServiceFee decimal.Decimal `db:"unit_service_fee"` ServiceExpiration Date CreatedAt time.Time CreatedBy *string LastModifiedAt time.Time LastModifiedBy *string DeletedAt *time.Time DeletedBy *string } type UserWithDetail struct { Id string Username string ResetNeeded bool UserType int16 `db:"type"` Enabled bool Name *string Abbr *string Region *string Address *string Contact *string Phone *string UnitServiceFee decimal.Decimal `db:"unit_service_fee"` ServiceExpiration Date CreatedAt time.Time CreatedBy *string LastModifiedAt time.Time LastModifiedBy *string }