notificationmodal

package module
v0.0.0-...-461bb6a Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 7 Imported by: 0

README

Notification-Model

This is a sample go package.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EntityTypes = map[string]interface{}{
	"user":   true,
	"lead":   true,
	"public": true,
}
View Source
var NotificationStatus = map[string]interface{}{
	"draft":           true,
	"sending_request": true,
	"failed":          true,
	"completed":       true,
}
View Source
var NotificationTypes = map[string]interface{}{
	"mail": true,
}

Functions

func PermitParams

func PermitParams(fields []string, params map[string]interface{}) map[string]interface{}

func ValidatePresenceOfParams

func ValidatePresenceOfParams(queryParams map[string]interface{}, paramsToBeValidated ...string) (bool, string, string)

Types

type GormBase

type GormBase struct {
	ID        string     `json:"id" sql:"type:uuid;primary_key;default:uuid_generate_v4()" gorm:"type:uuid"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"update_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`
}

func (*GormBase) BeforeCreate

func (gormBase *GormBase) BeforeCreate(tx *gorm.DB) (err error)

type JSONB

type JSONB map[string]interface{}

func (*JSONB) Scan

func (j *JSONB) Scan(value interface{}) error

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

type Notification

type Notification struct {
	GormBase
	EntityID         string    `json:"entity_id" sql:"type:uuid" gorm:"type:uuid; index"`
	EntityType       string    `json:"entity_type" gorm:"type:varchar(10); index; not null"`
	NotificationType string    `json:"type" gorm:"type:varchar(16); index; not null;"`
	RequestData      JSONB     `json:"request_data" sql:"type:jsonb" gorm:"type:jsonb"`
	ResponseData     JSONB     `json:"response_data" sql:"type:jsonb" gorm:"type:jsonb"`
	Status           string    `json:"status" gorm:"type:varchar(32); not null; index; default:draft"`
	Success          bool      `json:"success" gorm:"default:false;"`
	SentTime         time.Time `json:"sent_time"`
}

func CreateNotification

func CreateNotification(Db *gorm.DB, params map[string]interface{}) (Notification, bool, string, string)

Function to create Notification Object

func (Notification) BeforeSave

func (notification Notification) BeforeSave(tx *gorm.DB) (err error)

Jump to

Keyboard shortcuts

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