model

package
v0.0.0-...-23ae872 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeInvite  string = "invite"
	EventTypePost    string = "post"
	EventTypeMessage string = "message"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Id        int64     `db:"id" json:"id,omitempty"`
	Title     string    `db:"title" json:"title,omitempty"`
	CreatedAt time.Time `db:"created_at" json:"created_at,omitempty"`
	Closed    bool      `db:"closed" json:"closed,omitempty"`
}

Chat Чат общение между двумя и более участниками

type ChatCreateDTO

type ChatCreateDTO struct {
	Title string  `json:"title,omitempty"`
	Users []int64 `json:"users"`
}

type ChatParticipant

type ChatParticipant struct {
	Id     int64 `json:"id,omitempty" db:"id"`
	ChatId int64 `json:"chat_id" db:"chat_id"`
	UserId int64 `json:"user_id" db:"user_id"`
	Status int8  `json:"status" db:"status"`
}

ChatParticipant Список участников чата

type ChatParticipantsDTO

type ChatParticipantsDTO struct {
	UserName string `json:"user_name"`
	Status   string `json:"status"`
}

ChatParticipantsDTO Участник чата (для отображения Клиенту)

type Event

type Event interface {
	String() string
	GetType() string
}

type EventChatInvite

type EventChatInvite struct {
	EventType string `json:"event"`
	Chat      Chat   `json:"chat"`
}

EventChatInvite Событие приглашение в чат

func (*EventChatInvite) GetType

func (e *EventChatInvite) GetType() string

func (*EventChatInvite) String

func (e *EventChatInvite) String() string

type EventChatMessage

type EventChatMessage struct {
	EventType  string `json:"event"`
	Chat       Chat   `json:"chat"`
	MessageDTO `json:"data"`
}

EventChatMessage Событие Сообщение в чате

func (*EventChatMessage) GetType

func (e *EventChatMessage) GetType() string

func (*EventChatMessage) String

func (e *EventChatMessage) String() string

type EventPost

type EventPost struct {
	EventType string  `json:"event"`
	Data      PostDTO `json:"data"`
}

EventPost Событие Публикация

func (*EventPost) GetType

func (e *EventPost) GetType() string

func (*EventPost) String

func (e *EventPost) String() string

type Friend

type Friend struct {
	UserId   int64 `json:"user_id" db:"user_id"`
	FriendId int64 `json:"friend_id" db:"friend_id"`
}

Friend Друг друга

type Message

type Message struct {
	Id       int64     `json:"id,omitempty" db:"id"`
	ChatId   int64     `json:"chat_id" db:"chat_id"`
	UserFrom int64     `json:"user_from" db:"user_from"`
	SendAt   time.Time `json:"send_at" db:"send_at"`
	Message  string    `json:"message" db:"message"`
}

Message Сообщение, которое сохраняется в БД

type MessageDTO

type MessageDTO struct {
	Id       int64     `json:"id"`
	UserFrom string    `json:"user_from"`
	Date     time.Time `json:"date"`
	Message  string    `json:"message"`
}

MessageDTO Сообщение (для отображения Клиентом)

type MessageList

type MessageList struct {
	Chat Chat         `json:"chat"`
	List []MessageDTO `json:"list"`
}

MessageList Список сообщений чата

type MessageSendDTO

type MessageSendDTO struct {
	ChatId  int64  `json:"chat_id,omitempty" `
	Message string `json:"message"`
}

type Post

type Post struct {
	Id        int64     `json:"id" db:"id" fake:"skip"`
	UserId    int64     `json:"user_id" db:"user_id" fake:"skip"`
	Title     string    `json:"title" db:"title" fake:"{sentence}"`
	Message   string    `json:"message" db:"message" fake:"{sentence}"`
	CreatedAt time.Time `json:"created_at" db:"created_at" fake:"skip"`
	UpdateAt  time.Time `json:"updated_at" db:"updated_at" fake:"skip"`
	Deleted   bool      `json:"deleted" db:"deleted" fake:"skip"`
}

Post model

type PostDTO

type PostDTO struct {
	UserFrom string `json:"user_from"`
	Title    string `json:"title"`
	Message  string `json:"message"`
}

PostDTO Публикация (для отображения на клиенте)

type PostPojo

type PostPojo struct {
	UserId  int64  `fake:"skip"`
	Title   string `json:"title" db:"title" fake:"{sentence}"`
	Message string `json:"message" db:"message" fake:"{sentence}"`
}

PostPojo model

type User

type User struct {
	UserId       int64        `json:"id" db:"user_id" fake:"skip"`
	Login        string       `json:"login" db:"login" fake:"{regex:[abcdefghijklmnopqrstuvwxyz0123456789]{10}}"`
	Email        string       `json:"email" db:"email" fake:"{email}"`
	Phone        string       `json:"phone" db:"phone" fake:"{phone}"`
	Name         string       `json:"name" db:"name" fake:"{firstname}"`
	Surname      string       `json:"surname" db:"surname" fake:"{lastname}"`
	Age          int          `json:"age" db:"age" fake:"{number:1,100}"`
	Sex          string       `json:"sex" db:"sex" fake:"{randomstring:[male,female]}""`
	Country      string       `json:"country" db:"country" fake:"{country}"`
	City         string       `json:"city" db:"city" fake:"{city}"`
	Interests    string       `json:"interests" db:"interests" fake:"{sentence}"`
	Password     string       `json:"password,omitempty" db:"-" fake:"{password}"`
	PasswordHash string       `json:"-" db:"password" fake:"skip"`
	ShardId      string       `json:"-" db:"shard_id"`
	Settings     UserSettings `json:"settings,omitempty" db:"-"`
}

User model

func (*User) ValidateRegister

func (u *User) ValidateRegister() error

func (*User) ValidateUpdate

func (u *User) ValidateUpdate() (map[string]struct{}, error)

type UserSettings

type UserSettings struct {
	WSConnect string `json:"ws_connect_uri"`
}

type WsEvent

type WsEvent struct {
	UserId  int64  `json:"user_id"`
	Message string `json:"message,omitempty"`
}

WsEvent Используется для маршрутизации и отправки пользователю в websocket

Jump to

Keyboard shortcuts

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