types

package
v0.0.0-...-f5dcb26 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidPassword

func IsValidPassword(encpw, pw string) bool

Types

type AdminRegisterParams

type AdminRegisterParams struct {
	IsAdmin  bool   `json:"is_admin"`
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type CreatePostParams

type CreatePostParams struct {
	Author  uuid.UUID `json:"author"`
	Content string    `json:"content"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*CreateUserParams) Validate

func (p *CreateUserParams) Validate() map[string]string

type LoginUser

type LoginUser struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Post

type Post struct {
	ID        uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primarykey" json:"Id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Content   string    `json:"content"`
	Author    uuid.UUID `json:"author"`
}

func CreatePostFromParams

func CreatePostFromParams(params CreatePostParams) *Post

type PostResponse

type PostResponse struct {
	ID        uuid.UUID `json:"Id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Content   string    `json:"content"`
}

type Profile

type Profile struct {
	UserId            uuid.UUID
	SubscriberCount   uint `json:"subscriberCount"`
	SubscriptionCount uint `json:"subscriptionCount"`
}

type ResponseUser

type ResponseUser struct {
	ID        uuid.UUID `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Post      []Post    `json:"posts"`
}

func UsersToUserResponses

func UsersToUserResponses(users []*User) []ResponseUser

type SubscriberResponse

type SubscriberResponse struct {
	Username string `json:"username"`
	Email    string `json:"email"`
}

func UserToSubscriberResponse

func UserToSubscriberResponse(user []*User) []SubscriberResponse

type Subscription

type Subscription struct {
	ID           uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primarykey" json:"Id"`
	SubscriberID uuid.UUID `json:"subscriberId"`
	TargetID     uuid.UUID `json:"targetId"`
}

type SubscriptionResponse

type SubscriptionResponse struct {
	Username string `json:"username"`
}

type UpdateUsernameParams

type UpdateUsernameParams struct {
	Username string `json:"username"`
}

type User

type User struct {
	ID         uuid.UUID      `gorm:"type:uuid;default:uuid_generate_v4();primarykey" json:"Id"`
	CreatedAt  time.Time      `gorm:"not null" json:"created_at"`
	UpdatedAt  time.Time      `gorm:"not null" json:"updated_at"`
	Username   string         `gorm:"unique;size:100" json:"username"`
	Password   string         `gorm:"size:100" json:"password"`
	Email      string         `gorm:"unique;size:100" json:"email"`
	Post       []Post         `gorm:"foreignKey:Author;constraint:OnDelete:CASCADE"`
	IsAdmin    bool           `gorm:"default:false"`
	Subscriber []Subscription `gorm:"foreignKey:SubscriberID;constraint:OnDelete:CASCADE"`
	Target     []Subscription `gorm:"foreignKey:TargetID;constraint:OnDelete:CASCADE"`
	Profile    Profile
}

func NewUserFromParams

func NewUserFromParams(params CreateUserParams) (*User, error)

func (*User) ResponseUser

func (u *User) ResponseUser() *ResponseUser

func (*User) SubcriberResponse

func (u *User) SubcriberResponse() *SubscriberResponse

Jump to

Keyboard shortcuts

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