models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLog

type AppLog struct {
	ID        int        `json:"id"`
	Level     string     `json:"level"`
	Message   string     `json:"message"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
}

func (*AppLog) Count

func (m *AppLog) Count() int

func (*AppLog) Create

func (m *AppLog) Create(level, message string) error

func (*AppLog) Get

func (m *AppLog) Get(offset, limit int, level string) ([]*AppLog, error)

type Group

type Group struct {
	ID        int        `json:"id"`
	UID       int        `json:"uid" validate:"number"`
	UserID    int        `json:"user_id" validate:"number"`
	Name      string     `json:"name" validate:"required"`
	Active    bool       `json:"active" validate:"boolean"`
	Parent    *Group     `json:"parent,omitempty"`
	User      *User      `json:"user,omitempty"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (*Group) Count

func (m *Group) Count(userID int) int

func (*Group) Create

func (m *Group) Create(exec any) error

func (*Group) Delete

func (m *Group) Delete(id, userID int) error

func (*Group) Get

func (m *Group) Get(userID, id, uid int) ([]*Group, error)

func (*Group) IDExists

func (m *Group) IDExists(id, userID int) (bool, error)

func (*Group) NameExists

func (m *Group) NameExists() (bool, error)

func (*Group) Paginate

func (m *Group) Paginate(userID, offset, limit int, search string) []*Group

func (*Group) Update

func (m *Group) Update(query string, params []any) error

type GroupUpdate

type GroupUpdate struct {
	UID    int    `json:"uid" validate:"omitempty,number"`
	UserID int    `json:"user_id" validate:"omitempty,number"`
	Name   string `json:"name" validate:"omitempty"`
	Active *bool  `json:"active" validate:"omitnil,boolean"`
}

type Login

type Login struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required,min=6"`
}

type Notification

type Notification struct {
	ID             int              `json:"id"`
	UserID         int              `json:"user_id" validate:"number"`
	Title          string           `json:"title" validate:"required"`
	Content        string           `json:"content" validate:"required"`
	IsMail         bool             `json:"is_mail" validate:"boolean"`
	IsMessage      bool             `json:"is_message" validate:"boolean"`
	Active         bool             `json:"active" validate:"boolean"`
	User           *User            `json:"user,omitempty"`
	NotifyEmails   []*NotifyEmail   `json:"emails,omitempty"`
	NotifyMessages []*NotifyMessage `json:"messages,omitempty"`
	CreatedAt      *time.Time       `json:"created_at,omitempty"`
	UpdatedAt      *time.Time       `json:"updated_at,omitempty"`
	DeletedAt      *time.Time       `json:"deleted_at,omitempty"`
}

func (*Notification) Count

func (m *Notification) Count(userId int) int

func (*Notification) Create

func (m *Notification) Create(exec any) error

func (*Notification) Delete

func (m *Notification) Delete(id, userID int) error

func (*Notification) Get

func (m *Notification) Get(userID, id int, title string) ([]*Notification, error)

func (*Notification) IDExists

func (m *Notification) IDExists(id, userID int) (bool, error)

func (*Notification) Paginate

func (m *Notification) Paginate(userID, offset, limit int, search string) []*Notification

func (*Notification) TitleExists

func (m *Notification) TitleExists() (bool, error)

func (*Notification) Update

func (m *Notification) Update(query string, params []any) error

type NotificationBulk

type NotificationBulk struct {
	UserID         int                  `json:"user_id" validate:"number"`
	Title          string               `json:"title" validate:"required"`
	Content        string               `json:"content" validate:"required"`
	IsMail         bool                 `json:"is_mail" validate:"boolean"`
	IsMessage      bool                 `json:"is_message" validate:"boolean"`
	Active         bool                 `json:"active" validate:"boolean"`
	NotifyEmails   []*NotifyEmailBulk   `json:"notify_emails" validate:"required_without=NotifyMessages,dive"`
	NotifyMessages []*NotifyMessageBulk `json:"notify_messages" validate:"required_without=NotifyEmails,dive"`
}

type NotificationUpdate

type NotificationUpdate struct {
	UserID    int    `json:"user_id" validate:"omitempty,number"`
	Title     string `json:"title" validate:"omitempty"`
	Content   string `json:"content" validate:"omitempty"`
	IsMessage *bool  `json:"is_message" validate:"omitnil,boolean"`
	IsMail    *bool  `json:"is_mail" validate:"omitnil,boolean"`
	Active    *bool  `json:"active" validate:"omitnil,boolean"`
}

type NotifyEmail

type NotifyEmail struct {
	ID             int           `json:"id"`
	NotificationID int           `json:"notification_id" validate:"required,number"`
	Email          string        `json:"email" validate:"required,email"`
	Active         bool          `json:"active" validate:"boolean"`
	Notification   *Notification `json:"notification,omitempty"`
	CreatedAt      *time.Time    `json:"created_at,omitempty"`
	UpdatedAt      *time.Time    `json:"updated_at,omitempty"`
	DeletedAt      *time.Time    `json:"deleted_at,omitempty"`
}

func (*NotifyEmail) Count

func (m *NotifyEmail) Count(userId int) int

func (*NotifyEmail) Create

func (m *NotifyEmail) Create(exec any) error

func (*NotifyEmail) Delete

func (m *NotifyEmail) Delete(id, userID int) error

func (*NotifyEmail) EmailExists

func (m *NotifyEmail) EmailExists(exec any, userID int) (bool, error)

func (*NotifyEmail) Get

func (m *NotifyEmail) Get(userID, id int, email string) ([]*NotifyEmail, error)

func (*NotifyEmail) IDExists

func (m *NotifyEmail) IDExists(id, userID int) (bool, error)

func (*NotifyEmail) Paginate

func (m *NotifyEmail) Paginate(userID, offset, limit int, search string) []*NotifyEmail

func (*NotifyEmail) Update

func (m *NotifyEmail) Update(query string, params []any) error

type NotifyEmailBulk

type NotifyEmailBulk struct {
	NotificationID int    `json:"notification_id" validate:"number"`
	Email          string `json:"email" validate:"required,email"`
	Active         bool   `json:"active" validate:"boolean"`
}

type NotifyEmailUpdate

type NotifyEmailUpdate struct {
	NotificationID int    `json:"notification_id" validate:"omitempty,number"`
	Email          string `json:"email" validate:"omitempty,email"`
	Active         *bool  `json:"active" validate:"omitnil,boolean"`
}

type NotifyMessage

type NotifyMessage struct {
	ID             int           `json:"id"`
	NotificationID int           `json:"notification_id" validate:"required,number"`
	Phone          string        `json:"phone" validate:"required,e164"`
	Active         bool          `json:"active" validate:"boolean"`
	Notification   *Notification `json:"notification,omitempty"`
	CreatedAt      *time.Time    `json:"created_at,omitempty"`
	UpdatedAt      *time.Time    `json:"updated_at,omitempty"`
	DeletedAt      *time.Time    `json:"deleted_at,omitempty"`
}

func (*NotifyMessage) Count

func (m *NotifyMessage) Count(userId int) int

func (*NotifyMessage) Create

func (m *NotifyMessage) Create(exec any) error

func (*NotifyMessage) Delete

func (m *NotifyMessage) Delete(id, userID int) error

func (*NotifyMessage) Get

func (m *NotifyMessage) Get(userID, id int, phone string) ([]*NotifyMessage, error)

func (*NotifyMessage) IDExists

func (m *NotifyMessage) IDExists(id, userID int) (bool, error)

func (*NotifyMessage) Paginate

func (m *NotifyMessage) Paginate(userID, offset, limit int, search string) []*NotifyMessage

func (*NotifyMessage) PhoneExists

func (m *NotifyMessage) PhoneExists(exec any, userID int) (bool, error)

func (*NotifyMessage) Update

func (m *NotifyMessage) Update(query string, params []any) error

type NotifyMessageBulk

type NotifyMessageBulk struct {
	NotificationID int    `json:"notification_id" validate:"number"`
	Phone          string `json:"phone" validate:"required,e164"`
	Active         bool   `json:"active" validate:"boolean"`
}

type NotifyMessageUpdate

type NotifyMessageUpdate struct {
	NotificationID int    `json:"notification_id" validate:"omitempty,number"`
	Phone          string `json:"phone" validate:"omitempty,e164"`
	Active         *bool  `json:"active" validate:"omitnil,boolean"`
}

type PasswordUpdate

type PasswordUpdate struct {
	ID         int    `json:"id" validate:"omitempty"` // This field is required if the administrator wants to update a user.
	Password   string `json:"password" validate:"required,min=6"`
	RePassword string `json:"re-password" validate:"required,min=6"`
}

type ProfileUpdate

type ProfileUpdate struct {
	ID       int    `json:"id" validate:"omitempty"` // This field is required if the administrator wants to update a user.
	Fullname string `json:"fullname" validate:"omitempty"`
	Email    string `json:"email" validate:"omitempty,email"`
	Phone    string `json:"phone" validate:"omitempty,e164"`
}

type Register

type Register struct {
	Fullname string `json:"fullname" validate:"required"`
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required,min=6"`
	Phone    string `json:"phone" validate:"required,e164"`
}

type Request

type Request struct {
	ID             int              `json:"id"`
	UserID         int              `json:"user_id" validate:"number"`
	Url            string           `json:"url" validate:"required,url"`
	Method         string           `json:"method" validate:"required,oneof=GET POST PUT PATCH"`
	Content        json.RawMessage  `json:"content" validate:"omitempty,json"`
	Active         bool             `json:"active" validate:"boolean"`
	User           *User            `json:"user,omitempty"`
	RequestHeaders []*RequestHeader `json:"request_headers,omitempty"`
	CreatedAt      *time.Time       `json:"created_at,omitempty"`
	UpdatedAt      *time.Time       `json:"updated_at,omitempty"`
	DeletedAt      *time.Time       `json:"deleted_at,omitempty"`
}

func (*Request) Count

func (m *Request) Count(userID int) int

func (*Request) Create

func (m *Request) Create(exec any) error

func (*Request) Delete

func (m *Request) Delete(id, userID int) error

func (*Request) Get

func (m *Request) Get(userID, id int, url string) ([]*Request, error)

func (*Request) IDExists

func (m *Request) IDExists(id, userID int) (bool, error)

func (*Request) Paginate

func (m *Request) Paginate(userID, offset, limit int, search string) []*Request

func (*Request) Update

func (m *Request) Update(query string, params []any) error

func (*Request) UrlExists

func (m *Request) UrlExists() (bool, error)

type RequestBulk

type RequestBulk struct {
	UserID         int                  `json:"user_id" validate:"number"`
	Url            string               `json:"url" validate:"required,url"`
	Method         string               `json:"method" validate:"required,oneof=GET POST PUT PATCH"`
	Content        string               `json:"content" validate:"omitempty,json"`
	Active         bool                 `json:"active" validate:"boolean"`
	RequestHeaders []*RequestHeaderBulk `json:"request_headers" validate:"required,nonempty,dive"`
}

type RequestHeader

type RequestHeader struct {
	ID        int        `json:"id"`
	RequestID int        `json:"request_id" validate:"required,number"`
	Key       string     `json:"key" validate:"required"`
	Value     string     `json:"value" validate:"required"`
	Active    bool       `json:"active" validate:"boolean"`
	Request   *Request   `json:"request,omitempty"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (*RequestHeader) Count

func (m *RequestHeader) Count(userID int) int

func (*RequestHeader) Create

func (m *RequestHeader) Create(exec any) error

func (*RequestHeader) Delete

func (m *RequestHeader) Delete(id, userID int) error

func (*RequestHeader) Get

func (m *RequestHeader) Get(userID, id, requestID int, key string) ([]*RequestHeader, error)

func (*RequestHeader) HeaderExists

func (m *RequestHeader) HeaderExists(exec any, userID int) (bool, error)

func (*RequestHeader) IDExists

func (m *RequestHeader) IDExists(id, userID int) (bool, error)

func (*RequestHeader) Paginate

func (m *RequestHeader) Paginate(userID, offset, limit int, search string) []*RequestHeader

func (*RequestHeader) Update

func (m *RequestHeader) Update(query string, params []any) error

type RequestHeaderBulk

type RequestHeaderBulk struct {
	RequestID int    `json:"request_id" validate:"number"`
	Key       string `json:"key" validate:"required"`
	Value     string `json:"value" validate:"required"`
	Active    bool   `json:"active" validate:"boolean"`
}

type RequestHeaderUpdate

type RequestHeaderUpdate struct {
	RequestID int    `json:"request_id" validate:"omitempty,number"`
	Key       string `json:"key" validate:"omitempty"`
	Value     string `json:"value" validate:"omitempty"`
	Active    *bool  `json:"active" validate:"omitnil,boolean"`
}

type RequestUpdate

type RequestUpdate struct {
	UserID  int    `json:"user_id" validate:"omitempty,number"`
	Url     string `json:"url" validate:"omitempty,url"`
	Method  string `json:"method" validate:"omitempty,oneof=GET POST PUT PATCH"`
	Content string `json:"content" validate:"omitempty,json"`
	Active  *bool  `json:"active" validate:"omitnil,boolean"`
}

type Schedule

type Schedule struct {
	ID             int           `json:"id"`
	UserID         int           `json:"user_id" validate:"number"`
	GroupID        int           `json:"group_id" validate:"required,number"`
	RequestID      int           `json:"request_id" validate:"required,number"`
	NotificationID int           `json:"notification_id" validate:"required,number"`
	Timing         string        `json:"timing" validate:"required,cron"` // https://crontab.guru/
	Timeout        int           `json:"timeout" validate:"number"`
	Retries        int           `json:"retries" validate:"number"`
	Running        bool          `json:"running" validate:"boolean"`
	Active         bool          `json:"active" validate:"boolean"`
	User           *User         `json:"user,omitempty"`
	Group          *Group        `json:"group,omitempty"`
	Request        *Request      `json:"request,omitempty"`
	Notification   *Notification `json:"notification,omitempty"`
	Webhooks       []*Webhook    `json:"webhooks,omitempty"`
	CreatedAt      *time.Time    `json:"created_at,omitempty"`
	UpdatedAt      *time.Time    `json:"updated_at,omitempty"`
	DeletedAt      *time.Time    `json:"deleted_at,omitempty"`
}

func (*Schedule) Count

func (m *Schedule) Count(userID int) int

func (*Schedule) Create

func (m *Schedule) Create(exec any) error

func (*Schedule) Delete

func (m *Schedule) Delete(id, userID int) error

func (*Schedule) Get

func (m *Schedule) Get(id, userID, groupID, requestID, NotificationID int, timing string) ([]*Schedule, error)

func (*Schedule) IDExists

func (m *Schedule) IDExists(id, userID int) (bool, error)

func (*Schedule) Paginate

func (m *Schedule) Paginate(userID, offset, limit int, search string) []*Schedule

func (*Schedule) TimingExists

func (m *Schedule) TimingExists(userID int) (bool, error)

func (*Schedule) Update

func (m *Schedule) Update(query string, params []any) error

func (*Schedule) WithQuery

func (m *Schedule) WithQuery(userID, offset, limit int, search string) []*Schedule

func (*Schedule) WithQueryAll

func (m *Schedule) WithQueryAll() []*Schedule

type ScheduleBulk

type ScheduleBulk struct {
	UserID         int               `json:"user_id" validate:"number"`
	GroupID        int               `json:"group_id" validate:"number"`
	RequestID      int               `json:"request_id" validate:"number"`
	NotificationID int               `json:"notification_id" validate:"number"`
	Timing         string            `json:"timing" validate:"required,cron"`
	Timeout        int               `json:"timeout" validate:"number"`
	Retries        int               `json:"retries" validate:"number"`
	Running        bool              `json:"running" validate:"boolean"`
	Active         bool              `json:"active" validate:"boolean"`
	Group          *Group            `json:"group" validate:"omitempty"`
	Request        *RequestBulk      `json:"request" validate:"omitempty"`
	Notification   *NotificationBulk `json:"notification" validate:"omitempty"`
}

type ScheduleLog

type ScheduleLog struct {
	ID         int        `json:"id"`
	ScheduleID int        `json:"schedule_id" validate:"required"`
	Took       float32    `json:"took" validate:"required"`
	Result     any        `json:"result" validate:"required"`
	Schedule   *Schedule  `json:"schedule,omitempty"`
	StartedAt  *time.Time `json:"started_at,omitempty"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
	CreatedAt  *time.Time `json:"created_at,omitempty"`
}

func (*ScheduleLog) Count

func (m *ScheduleLog) Count(userID int) int

func (*ScheduleLog) Create

func (m *ScheduleLog) Create(scheduleId int) error

func (*ScheduleLog) Get

func (m *ScheduleLog) Get(id, schedule_id, user_id int) ([]*ScheduleLog, error)

func (*ScheduleLog) Paginate

func (m *ScheduleLog) Paginate(userID, offset, limit int, search string) []*ScheduleLog

type ScheduleUpdate

type ScheduleUpdate struct {
	GroupID        int    `json:"group_id" validate:"omitempty,number"`
	RequestID      int    `json:"request_id" validate:"omitempty,number"`
	NotificationID int    `json:"notification_id" validate:"omitempty,number"`
	Timing         string `json:"timing" validate:"omitempty,cron"`
	Timeout        *int   `json:"timeout" validate:"omitnil,number"`
	Retries        *int   `json:"retries" validate:"omitnil,number"`
	Active         *bool  `json:"active" validate:"omitnil,boolean"`
}

type Triggered

type Triggered struct {
	ID         int `json:"id"`
	ScheduleID int `json:"schedule_id"`
}

func (*Triggered) Create

func (m *Triggered) Create(schedule_id int) error

func (*Triggered) Delete

func (m *Triggered) Delete(schedule_id int) error

type User

type User struct {
	ID        int        `json:"id"`
	Fullname  string     `json:"fullname" validate:"required"`
	Email     string     `json:"email" validate:"required,email"`
	Password  string     `json:"-" validate:"required"`
	Phone     string     `json:"phone" validate:"required,e164"`
	Active    bool       `json:"active"`
	IsAdmin   bool       `json:"is_admin"`
	LastLogin *time.Time `json:"last_login,omitempty"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (*User) Count

func (m *User) Count() int

func (*User) Create

func (m *User) Create(register *Register) error

func (*User) Delete

func (m *User) Delete(userID int) error

func (*User) Exists

func (m *User) Exists(email string) (bool, error)

func (*User) Get

func (m *User) Get(offset, limit int, search string) []*User

func (*User) GetWithId

func (m *User) GetWithId(id int) error

func (*User) GetWithMail

func (m *User) GetWithMail(email string) error

func (*User) IDExists

func (m *User) IDExists(id int) (bool, error)

func (*User) LastLoginUpdate

func (m *User) LastLoginUpdate() error

func (*User) PasswordUpdate

func (m *User) PasswordUpdate(password string) error

func (*User) ProfileUpdate

func (m *User) ProfileUpdate(query string, params []any) error

type Webhook

type Webhook struct {
	ID         int        `json:"id"`
	ScheduleID int        `json:"schedule_id" validate:"required,number"`
	RequestID  int        `json:"request_id" validate:"required,number"`
	Active     bool       `json:"active" validate:"boolean"`
	Schedule   *Schedule  `json:"schedule,omitempty"`
	Request    *Request   `json:"request,omitempty"`
	CreatedAt  *time.Time `json:"created_at,omitempty"`
	UpdatedAt  *time.Time `json:"updated_at,omitempty"`
	DeletedAt  *time.Time `json:"deleted_at,omitempty"`
}

func (*Webhook) Count

func (m *Webhook) Count(userID int) int

func (*Webhook) Create

func (m *Webhook) Create() error

func (*Webhook) Delete

func (m *Webhook) Delete(id, userID int) error

func (*Webhook) Get

func (m *Webhook) Get(id, schedule_id, request_id, user_id int) ([]*Webhook, error)

func (*Webhook) IDExists

func (m *Webhook) IDExists(id, userID int) (bool, error)

func (*Webhook) Paginate

func (m *Webhook) Paginate(userID, offset, limit int, search string) []*Webhook

func (*Webhook) UniqExists

func (m *Webhook) UniqExists(scheduleID, requestID, userID int) (bool, error)

func (*Webhook) Update

func (m *Webhook) Update(query string, params []any) error

type WebhookUpdate

type WebhookUpdate struct {
	ScheduleID int   `json:"schedule_id" validate:"omitempty,number"`
	RequestID  int   `json:"request_id" validate:"omitempty,number"`
	Active     *bool `json:"active" validate:"omitnil,boolean"`
}

Jump to

Keyboard shortcuts

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