users

package
v0.0.0-...-be41bbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(user interface{}) (util.Entity, error)

CreateUser creates a new user using the specified model

func DeleteUser

func DeleteUser(id int) error

DeleteUser deletes the user with the specified ID

func GetUser

func GetUser(id int) (util.Entity, error)

GetUser returns a specific user

func PatchUser

func PatchUser(user interface{}) error

PatchUser does a partial update on the specified user

func Register

func Register(e *echo.Group, database *gorm.DB, config *Config)

Register initializes the users package

func UpdateUser

func UpdateUser(user interface{}) error

UpdateUser updates a specified user

Types

type Config

type Config struct {
	ResultsPerPage int `mapstructure:"default-results-per-page"`
}

Config is the configuration for the user API

type User

type User struct {
	util.EntityImpl
	UserName string `gorm:"type:varchar(20);index;not null"`

	FirstName  string `gorm:"type:varchar(20);index;not null"`
	MiddleName string `gorm:"type:varchar(20)"`
	LastName   string `gorm:"type:varchar(50);index;not null"`

	PrimaryEmail string `gorm:"type:varchar(35);unique_index;not null"`
	Organization string `gorm:"type:varchar(10);index;not null"`
	Sex          string `gorm:"type:varchar(1)"`
}

User DTO

func GetUsers

func GetUsers(offset int, limit int) ([]*User, error)

GetUsers returns a page of users

func (User) TableName

func (User) TableName() string

TableName for users

type UserAttributes

type UserAttributes struct {
	UserID      uint `gorm:"index:att;not null"`
	AttributeID uint `gorm:"index:att;not null"`
}

type UserRegistration

type UserRegistration struct {
	FirstName  string  `json:"firstName"`
	MiddleName *string `json:"middleName;omitempty"`
	LastName   string  `json:"lastName"`
	Nickname   string  `json:"nickname"`

	UserName string `json:"userName"`
	Password string `json:"password"`

	PrimaryEmail string `json:"primaryEmail"`
	Organization string `json:"organization"`
	Gender       string `json:"gender" valid:"in(m|M|F|f)"`

	VerificationCode string `json:"verificationCode"`
}

UserRegistration data

func (*UserRegistration) Validate

func (reg *UserRegistration) Validate() ([]string, error)

Validate the UserRegistration this has to be in reference to fields.. find an elegant way to build that up for now just use an array of strings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL