entity

package
v0.0.0-...-3c0f6d4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	CommentID uuid.UUID `json:"comment_id" db:"comment_id" validate:"omitempty,uuid"`
	AuthorID  uuid.UUID `json:"author_id" db:"author_id" validate:"required"`
	NewsID    uuid.UUID `json:"news_id" db:"news_id" validate:"required"`
	Message   string    `json:"message" db:"message" validate:"required,gte=5"`
	Likes     int64     `json:"likes" db:"likes" validate:"omitempty"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Comment model

type CommentBase

type CommentBase struct {
	CommentID uuid.UUID `json:"comment_id" db:"comment_id" validate:"omitempty,uuid"`
	AuthorID  uuid.UUID `json:"author_id" db:"author_id" validate:"required"`
	Author    string    `json:"author" db:"author" validate:"required"`
	AvatarURL *string   `json:"avatar_url" db:"avatar_url"`
	Message   string    `json:"message" db:"message" validate:"required,gte=5"`
	Likes     int64     `json:"likes" db:"likes" validate:"omitempty"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Comment base response

type CommentsList

type CommentsList struct {
	TotalCount int            `json:"total_count"`
	TotalPages int            `json:"total_pages"`
	Page       int            `json:"page"`
	Size       int            `json:"size"`
	HasMore    bool           `json:"has_more"`
	Comments   []*CommentBase `json:"comments"`
}

Comment base list

type News

type News struct {
	NewsID    uuid.UUID `json:"news_id" db:"news_id" validate:"omitempty,uuid"`
	AuthorID  uuid.UUID `json:"author_id" db:"author_id" validate:"required"`
	Title     string    `json:"title" db:"title" validate:"required,gte=10"`
	Content   string    `json:"content" db:"content" validate:"required,gte=20"`
	ImageURL  *string   `json:"image_url,omitempty" db:"image_url" validate:"omitempty,lte=512,url"`
	Category  *string   `json:"category,omitempty" db:"category" validate:"omitempty,lte=10"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

News base model

type NewsBase

type NewsBase struct {
	NewsID    uuid.UUID `json:"news_id" db:"news_id" validate:"omitempty,uuid"`
	AuthorID  uuid.UUID `json:"author_id" db:"author_id" validate:"omitempty,uuid"`
	Title     string    `json:"title" db:"title" validate:"required,gte=10"`
	Content   string    `json:"content" db:"content" validate:"required,gte=20"`
	ImageURL  *string   `json:"image_url,omitempty" db:"image_url" validate:"omitempty,lte=512,url"`
	Category  *string   `json:"category,omitempty" db:"category" validate:"omitempty,lte=10"`
	Author    string    `json:"author" db:"author"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at"`
}

News base

type NewsList

type NewsList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	News       []*News `json:"news"`
}

News list response

type Session

type Session struct {
	SessionID string    `json:"session_id" redis:"session_id"`
	UserID    uuid.UUID `json:"user_id" redis:"user_id"`
}

Session model

type User

type User struct {
	ID          uuid.UUID `json:"user_id" db:"user_id" redis:"user_id" validate:"omitempty,uuid"`
	FirstName   string    `json:"first_name" db:"first_name" redis:"first_name" validate:"required_with,lte=30"`
	LastName    string    `json:"last_name" db:"last_name" redis:"last_name" validate:"required_with,lte=30"`
	Email       string    `json:"email" db:"email" redis:"email" validate:"omitempty,lte=60,email"`
	Password    string    `json:"password,omitempty" db:"password" redis:"password" validate:"required,gte=6"`
	Role        *string   `json:"role" db:"role" redis:"role" validate:"omitempty,lte=10"`
	Avatar      *string   `json:"avatar" db:"avatar" redis:"avatar"`
	PhoneNumber *string   `json:"phone_number" db:"phone_number" redis:"phone_number" validate:"omitempty,lte=20"`
	Address     *string   `json:"address" db:"address" redis:"address" validate:"omitempty,lte=250"`
	City        *string   `json:"city" db:"city" redis:"city" validate:"omitempty,lte=24"`
	Country     *string   `json:"country" db:"country" redis:"country" validate:"omitempty,lte=24"`
	Postcode    *int      `json:"postcode" db:"postcode" redis:"postcode" validate:"omitempty,lte=10"`
	Balance     float64   `json:"balance" db:"balance" redis:"balance"`
	CreatedAt   time.Time `json:"created_at" db:"created_at" redis:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at" redis:"updated_at"`
}

User model

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

Compare user password and payload

func (*User) HashPassword

func (u *User) HashPassword() error

Hash user password with bcrypt

func (*User) PrepareCreate

func (u *User) PrepareCreate() error

Prepare user struct for register

func (*User) PrepareUpdate

func (u *User) PrepareUpdate() error

Prepare user update

func (*User) SanitizePassword

func (u *User) SanitizePassword()

Sanitize user password

type UserWithToken

type UserWithToken struct {
	User  *User  `json:"user"`
	Token string `json:"token"`
}

Find user query

type UsersList

type UsersList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	Users      []*User `json:"users"`
}

Users List

Jump to

Keyboard shortcuts

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