package entity import ( "strings" "time" "bitbucket.org/nemt/nemt-portal-api/infra/errors" ) // User entity data type User struct { ID int64 `db:"user_id" json:"-"` UUID string `db:"user_uuid" json:"uuid"` Name string `db:"name" json:"name"` Member string `db:"member" json:"member"` BirthDate time.Time `db:"birth_date" json:"birthdate"` LoginID int64 `db:"login_id" json:"-"` LoginUUID string `db:"login_uuid" json:"loginuuid"` Email string `db:"email" json:"email"` PhoneNumber string `db:"phone_number" json:"phonenumber"` Pass string `db:"password" json:"pass"` LoginKey string `db:"login_key" json:"loginkey"` Gender string `db:"gender" json:"gender"` Active bool `db:"active" json:"active"` Created time.Time `db:"createat" json:"createat"` Updated time.Time `db:"updateat" json:"updateat"` Contacts []ContactInfo `db:"contacts" json:"contacts"` Rides []Ride `db:"rides" json:"rides"` Addresses []Address `db:"addresses" json:"addresses"` Profiles []Profile `json:"profiles,omitempty"` Types []OrganizationType `json:"types,omitempty"` Organizations []Organization `json:"organizations,omitempty"` } type ContactInfo struct { ID int64 `db:"contact_id" json:"contact_id"` Type ContactType `db:"contact_type" json:"contact_type"` UserID int64 `db:"user_id" json:"-"` Value string `db:"value" json:"value"` } type ContactType struct { ID int64 `db:"contact_type_id" json:"contact_type_id"` Key string `db:"contact_type_key" json:"contact_type_key"` Value string `db:"contact_type_value" json:"contact_type_value"` } // Validate validates the user entity state func (entity *User) Validate() error { if strings.TrimSpace(entity.Name) == "" { return errors.NewValidationError("name", "Nome do usuário é obrigatório") } return nil }