user

package
v0.0.0-...-92f7cd3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLIstLimit = 1000

MaxLIstLimit const

View Source
const TableName = "user"

TableName const

Variables

This section is empty.

Functions

This section is empty.

Types

type IRepository

type IRepository interface {
	// Get returns the album with the specified album ID.
	Get(ctx context.Context, id uint) (*User, error)
	// Count returns the number of albums.
	//Count(ctx context.Context) (uint, error)
	// Query returns the list of albums with the given offset and limit.
	Query(ctx context.Context, offset, limit uint) ([]User, error)
	SetDefaultConditions(conditions map[string]interface{})
	// Create saves a new album in the storage.
	Create(ctx context.Context, entity *User) error
	// Update updates the album with given ID in the storage.
	//Update(ctx context.Context, entity *User) error
	// Delete removes the album with given ID from the storage.
	//Delete(ctx context.Context, id uint) error
	First(ctx context.Context, user *User) (*User, error)
}

IRepository encapsulates the logic to access albums from the data source.

type IService

type IService interface {
	NewEntity() *User
	Get(ctx context.Context, id uint) (*User, error)
	Query(ctx context.Context, offset, limit uint) ([]User, error)
	List(ctx context.Context) ([]User, error)
	//Count(ctx context.Context) (uint, error)
	Create(ctx context.Context, entity *User) error
	//Update(ctx context.Context, id string, input *User) (*User, error)
	//Delete(ctx context.Context, id string) (error)
	First(ctx context.Context, user *User) (*User, error)
}

IService encapsulates usecase logic for user.

func NewService

func NewService(repo IRepository, logger log.ILogger) IService

NewService creates a new service.

type User

type User struct {
	ID        uint   `gorm:"PRIMARY_KEY" json:"id"`
	Name      string `gorm:"type:varchar(100);UNIQUE;INDEX" json:"username"`
	Passhash  string `gorm:"type:bytea" json:"-"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `gorm:"INDEX"`
}

User is the user entity

func New

func New() *User

New func is a constructor for the User

func (User) TableName

func (e User) TableName() string

TableName returns a name of a table

func (User) Validate

func (e User) Validate() error

Validate function for a validation

Jump to

Keyboard shortcuts

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