models

package
v0.0.0-...-9808740 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 6 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=10"`
	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=10"`
	Likes     int64     `json:"likes" db:"likes" validate:"omitempty"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Base Comment 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"`
}

All News response

type News

type News struct {
	NewsID    uuid.UUID `json:"news_id" db:"news_id" validate:"omitempty,uuid"`
	AuthorID  uuid.UUID `json:"author_id,omitempty" 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,omitempty" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitempty" 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"`
}

All News response

type Role

type Role struct {
	ID           int           `json:"id" db:"id" redis:"role_id" validate:"required"`
	Name         string        `json:"name" db:"name" redis:"role_name" validate:"omitempty,lte=30"`
	Description  string        `json:"description" db:"description" redis:"description"`
	ParentRoleId sql.NullInt64 `json:"parent_role_id" db:"parent_role_id" redis:"parent_role_id"`
}

type RolesList

type RolesList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	Roles      []*Role `json:"roles"`
}

type Session

type Session struct {
	SessionID string `json:"session_id" redis:"session_id"`
	UserID    int    `json:"user_id" redis:"user_id"`
}

Session model

type UploadInput

type UploadInput struct {
	File        io.Reader
	Name        string
	Size        int64
	ContentType string
	BucketName  string
}

AWS Upload Input

type User

type User struct {
	ID        int       `json:"id" db:"id" redis:"user_id" validate:"required"`
	Username  string    `json:"username,omitempty" db:"username" redis:"username" validate:"omitempty,lte=60"`
	Email     string    `json:"email,omitempty" db:"email" redis:"email" validate:"omitempty,lte=60,email"`
	Password  string    `json:"password,omitempty" db:"password" redis:"password" validate:"omitempty,required"`
	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at" redis:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at" redis:"updated_at"`
	LoginDate time.Time `json:"login_at" db:"login_at" redis:"login_at"`
}

User full model

func (*User) ComparePasswords

func (u *User) ComparePasswords(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 for register

func (*User) PrepareUpdate

func (u *User) PrepareUpdate() error

Prepare user for register

func (*User) SanitizePassword

func (u *User) SanitizePassword()

Sanitize user password

type UserWithRole

type UserWithRole struct {
	User User `json:"user" db:"user"`
	Role Role `json:"role" db:"role"`
}

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"`
}

All Users response

Jump to

Keyboard shortcuts

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