support

package
v0.0.0-...-fd9b9a1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var States = states{
	Open:     "open",
	Answered: "answered",
	Closed:   "closed",
	Deleted:  "deleted",
}

Functions

This section is empty.

Types

type AdminDto

type AdminDto struct {
	UUID         string     `json:"uuid"`
	User         User       `json:"user"`
	Subject      string     `json:"subject"`
	Messages     []*Message `json:"messages"`
	State        State      `json:"state"`
	IsUserClosed bool       `json:"isUserClosed"`
	ClosedAt     *time.Time `json:"closedAt"`
	UpdatedAt    *time.Time `json:"updatedAt"`
	CreatedAt    time.Time  `json:"createdAt"`
}

type AdminListDto

type AdminListDto struct {
	UUID      string     `json:"uuid"`
	User      User       `json:"user"`
	Subject   string     `json:"subject"`
	State     State      `json:"state"`
	UpdatedAt *time.Time `json:"updatedAt"`
	CreatedAt time.Time  `json:"createdAt"`
}

type DetailDto

type DetailDto struct {
	UUID         string            `json:"uuid"`
	Subject      string            `json:"subject"`
	Messages     []*UserMessageDto `json:"messages"`
	State        State             `json:"state"`
	IsUserClosed bool              `json:"isUserClosed"`
	ClosedAt     *time.Time        `json:"closedAt"`
	UpdatedAt    *time.Time        `json:"updatedAt"`
}

type Entity

type Entity struct {
	UUID         string     `json:"uuid" bson:"_id,omitempty"`
	User         *User      `json:"user" bson:"user"`
	Subject      string     `json:"subject" bson:"subject"`
	Messages     []*Message `json:"messages" bson:"messages"`
	State        State      `json:"state" bson:"state"`
	IsUserClosed bool       `json:"isUserClosed" bson:"is_user_closed"`
	ClosedAt     *time.Time `json:"closedAt" bson:"closed_at"`
	UpdatedAt    *time.Time `json:"updatedAt" bson:"updated_at"`
	CreatedAt    time.Time  `json:"createdAt" bson:"created_at"`
}

func (*Entity) ToAdmin

func (e *Entity) ToAdmin() AdminDto

func (*Entity) ToAdminList

func (e *Entity) ToAdminList() AdminListDto

func (*Entity) ToDetail

func (e *Entity) ToDetail() DetailDto

func (*Entity) ToList

func (e *Entity) ToList() ListDto

type Errors

type Errors interface {
	Failed(string) *i18np.Error
	InvalidUUID() *i18np.Error
	NotFound() *i18np.Error
}

type Factory

type Factory struct {
	Errors Errors
}

func NewFactory

func NewFactory() Factory

func (Factory) IsZero

func (f Factory) IsZero() bool

func (Factory) New

func (f Factory) New(cnf NewConfig) *Entity

type FilterEntity

type FilterEntity struct {
	Query string `query:"q,omitempty" validate:"omitempty,max=100"`
	State string `query:"state,omitempty" validate:"omitempty,oneof=open answered closed deleted"`
}

type Interest

type Interest struct {
	UUID  string `json:"uuid" bson:"uuid"`
	Email string `json:"email" bson:"email"`
}

type ListDto

type ListDto struct {
	UUID      string     `json:"uuid"`
	Subject   string     `json:"subject"`
	State     State      `json:"state"`
	UpdatedAt *time.Time `json:"updatedAt"`
	CreatedAt time.Time  `json:"createdAt"`
}

type Message

type Message struct {
	UUID         string    `json:"uuid" bson:"uuid"`
	InterestUUID string    `json:"interest_uuid,omitempty" bson:"interest_uuid,omitempty"`
	Text         string    `json:"text" bson:"text"`
	IsAdmin      bool      `json:"is_admin" bson:"is_admin"`
	IsDeleted    bool      `json:"is_deleted" bson:"is_deleted"`
	Date         time.Time `json:"date" bson:"date"`
}

type NewConfig

type NewConfig struct {
	User    *User
	Subject string
	Message string
}

type Repo

type Repo interface {
	// admin actions
	AdminFilter(ctx context.Context, filter FilterEntity, listConfig list.Config) (*list.Result[*Entity], *i18np.Error)
	AdminGet(ctx context.Context, uuid string) (*Entity, *i18np.Error)
	AdminClose(ctx context.Context, uuid string) *i18np.Error
	AdminDelete(ctx context.Context, uuid string) *i18np.Error
	AdminAddMessage(ctx context.Context, uuid string, adminId string, message string) *i18np.Error
	AdminUpdate(ctx context.Context, uuid string, subject string) *i18np.Error
	AdminRemoveMessage(ctx context.Context, uuid string, messageId string) *i18np.Error

	// user actions
	Create(ctx context.Context, entity *Entity) (*Entity, *i18np.Error)
	AddMessage(ctx context.Context, uuid string, message string, user WithUser) *i18np.Error
	Close(ctx context.Context, uuid string, user WithUser) *i18np.Error
	Delete(ctx context.Context, uuid string, user WithUser) *i18np.Error
	Get(ctx context.Context, uuid string, user WithUser) (*Entity, *i18np.Error)
	Filter(ctx context.Context, user WithUser, filter FilterEntity, listConfig list.Config) (*list.Result[*Entity], *i18np.Error)
}

func NewRepo

func NewRepo(collection *mongo.Collection, factory Factory) Repo

type State

type State string

type User

type User struct {
	UUID string `json:"uuid" bson:"uuid"`
	Name string `json:"name" bson:"name"`
}

type UserMessageDto

type UserMessageDto struct {
	Text    string    `json:"text"`
	IsAdmin bool      `json:"isAdmin"`
	Date    time.Time `json:"date"`
}

type WithUser

type WithUser struct {
	UUID string
	Name string
}

Jump to

Keyboard shortcuts

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