models

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuery

func GetQuery(qs string, query Query) error

GetQuery takes an Query interface value this is guaranteed to have an UnmarshlQueryString method. Then, use the method of parse the query string.

Types

type AppError

type AppError struct {
	Message       string `json:"message"`        // Message to be display to the end user without debugging information
	DetailedError string `json:"detailed_error"` // Internal error string to help the developer
	StatusCode    int    `json:"status_code"`    // The http status code
	Where         string `json:"where"`          // The function where it happened in the form of Struct.Func
}

AppError is a custom error struct to implement error interface

func NewAppError

func NewAppError(where string, message string, details string, status int) *AppError

NewAppError new a AppError

func (*AppError) Error

func (ae *AppError) Error() string

Error is a implemented method of AppError

type AuthenticatedResponse

type AuthenticatedResponse struct {
	ID        uint   `json:"id"`
	Privilege int    `json:"privilege"`
	FirstName string `json:"firstname"`
	LastName  string `json:"lastname"`
	Email     string `json:"email"`
	Jwt       string `json:"jwt"`
}

AuthenticatedResponse defines the user info fields

type Author

type Author struct {
	ID       bson.ObjectId `bson:"_id" json:"id"`
	JobTitle string        `bson:"job_title" json:"job_title"`
	Name     string        `bson:"name" json:"name"`
}

type Bookmark

type Bookmark struct {
	ID         uint       `gorm:"primary_key" json:"id"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	DeletedAt  *time.Time `json:"deleted_at"`
	Users      []User     `gorm:"many2many:users_bookmarks;"`
	Slug       string     `gorm:"size:100;not null" json:"slug" form:"slug" binding:"required"`
	Title      string     `gorm:"size:100;not null" json:"title" from:"title" binding:"required"`
	Desc       string     `gorm:"size:250" json:"desc" form:"desc"`
	Host       string     `gorm:"size:100;not null;" json:"host" form:"host" binding:"required"`
	Category   string     `gorm:"size:20" json:"category" form:"category"`
	IsExternal bool       `gorm:"default:0" json:"is_external" form:"is_external"`
	Thumbnail  string     `gorm:"size:512" json:"thumbnail" form:"thumbnail" binding:"required"`
	Authors    string     `gorm:"size:250" json:"authors" form:"authors"`
	PubDate    uint       `gorm:"not null;default:0" json:"published_date" form:"published_date"`
}

Bookmark this is bookmarks table description

type CardInfo

type CardInfo struct {
	BinCode     null.String `gorm:"column:card_info_bin_code;type:varchar(6)" json:"bin_code"`
	Country     null.String `gorm:"column:card_info_country;type:varchar(30)" json:"country"`
	CountryCode null.String `gorm:"column:card_info_country_code;type:varchar(10)" json:"country_code"`
	ExpiryDate  null.String `gorm:"column:card_info_expiry_date;type:varchar(6);" json:"expiry_date"`
	Funding     null.Int    `gorm:"column:card_info_funding;type:tinyint" json:"funding"`
	Issuer      null.String `gorm:"column:card_info_issuer;type:varchar(50)" json:"issuer"`
	LastFour    null.String `gorm:"column:card_info_last_four;type:varchar(4)" json:"last_four"`
	Level       null.String `gorm:"column:card_info_level;type:varchar(10)" json:"level"`
	Type        null.Int    `gorm:"column:card_info_type;type:tinyint" json:"type"`
}

type Cardholder

type Cardholder struct {
	Address     null.String `gorm:"column:cardholder_address;type:varchar(100)" json:"address"`
	Email       string      `gorm:"column:cardholder_email;type:varchar(100);not null" json:"email" binding:"omitempty,email"`
	Name        null.String `gorm:"column:cardholder_name;type:varchar(30)" json:"name"`
	NationalID  null.String `gorm:"column:cardholder_national_id;type:varchar(20)" json:"national_id"`
	PhoneNumber null.String `gorm:"column:cardholder_phone_number;type:varchar(20)" json:"phone_number"`
	ZipCode     null.String `gorm:"column:cardholder_zip_code;type:varchar(10)" json:"zip_code"`
}

type Category

type Category struct {
	ID        bson.ObjectId `bson:"_id" json:"id"`
	SortOrder uint          `bson:"sort_order" json:"sort_order"`
	Name      string        `bson:"name" json:"name"`
}

Category ...

type ContentBody

type ContentBody struct {
	APIData []bson.M `bson:"apiData" json:"api_data"`
}

ContentBody ...

type FullAuthor

type FullAuthor struct {
	Author
	Bio struct {
		Html string `bson:"html" json:"html"`
		Md   string `bson:"md" json:"md"`
	}
	Email     string      `bson:"email" json:"email"`
	Thumbnail *MongoImage `bson:"thumbnail" json:"thumbnail"`
	UpdatedAt time.Time   `bson:"updatedAt" json:"updated_at"`
}

type Image

type Image struct {
	ID             bson.ObjectId  `json:"id,omitempty" bson:"_id,omitempty"`
	Description    string         `json:"description,omitempty"`
	Copyright      string         `json:"copyright,omitempty"`
	Height         uint           `json:"height,omitempty"`
	Filetype       string         `json:"filetype,omitempty"`
	Width          uint           `json:"width,omitempty"`
	URL            string         `json:"url,omitempty"`
	ResizedTargets ResizedTargets `json:"resized_targets,omitempty"`
}

Image is used to return in response

type ImageAsset

type ImageAsset struct {
	Height uint   `bson:"height" json:"height"`
	Width  uint   `bson:"width" json:"width"`
	URL    string `bson:"url" json:"url"`
}

ImageAsset ...

type MetaOfResponse

type MetaOfResponse struct {
	Total  int `json:"total"`
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
}

type MongoImage

type MongoImage struct {
	ID          bson.ObjectId   `bson:"_id"`
	Description string          `bson:"description"`
	Copyright   string          `bson:"copyright"`
	Image       MongoImageAsset `bson:"image"`
}

MongoImage is the data structure returned by Mongo DB

func (*MongoImage) ToImage

func (mi *MongoImage) ToImage() (img Image)

ToImage transforms MongoImage to Image

type MongoImageAsset

type MongoImageAsset struct {
	Height         uint           `bson:"height" json:"height"`
	Filetype       string         `bson:"filetype" json:"filetype"`
	Width          uint           `bson:"width" json:"width"`
	URL            string         `bson:"url" json:"url"`
	ResizedTargets ResizedTargets `bson:"resizedTargets" json:"resized_targets"`
}

type MongoQuery

type MongoQuery struct {
	State      string               `bson:"state,omitempty" json:"state"`
	Slug       string               `bson:"slug,omitempty" json:"slug"`
	Style      string               `bson:"style,omitempty" json:"style"`
	IsFeatured bool                 `bson:"isFeatured,omitempty" json:"is_featured"`
	Categories MongoQueryComparison `bson:"categories,omitempty" json:"categories"`
	Tags       MongoQueryComparison `bson:"tags,omitempty" json:"tags"`
	Topics     MongoQueryComparison `bson:"topics,omitempty" json:"topics"`
	IDs        MongoQueryComparison `bson:"_id,omitempty" json:"ids"`
}

MongoQuery implements Query interface, which stores the JSON in Query field.

func (*MongoQuery) UnmarshalQueryString

func (query *MongoQuery) UnmarshalQueryString(qs string) error

UnmarshalQueryString is type-specific functions of MongoQuery type

type MongoQueryComparison

type MongoQueryComparison struct {
	In []bson.ObjectId `json:"in" bson:"$in,omitempty"`
}

MongoQueryComparison ...

type MongoVideo

type MongoVideo struct {
	ID    bson.ObjectId   `bson:"_id"`
	Title string          `bson:"title"`
	Video MongoVideoAsset `bson:"video"`
}

MongoVideo is the data structure returned by Mongo DB

func (*MongoVideo) ToVideo

func (mv *MongoVideo) ToVideo() (video Video)

ToVideo Transform MongoVideo to Video

type MongoVideoAsset

type MongoVideoAsset struct {
	Filetype string `bson:"filetype"`
	Size     uint   `bson:"size"`
	URL      string `bson:"url"`
}

type NewsEntity

type NewsEntity interface {
	SetEmbeddedAsset(string, interface{})
	GetEmbeddedAsset(string) []bson.ObjectId
}

NewsEntity defines the method of structs such `Topic`, `Post` ...etc

type OAuthAccount

type OAuthAccount struct {
	ID        uint        `gorm:"primary_key" json:"id"`
	CreatedAt time.Time   `json:"created_at"`
	UpdatedAt time.Time   `json:"updated_at"`
	DeletedAt *time.Time  `json:"deleted_at"`
	UserID    uint        `json:"user_id"`
	Type      string      `gorm:"size:10" json:"type"`  // Facebook / Google ...
	AId       null.String `gorm:"not null" json:"a_id"` // user ID returned by OAuth services
	Email     null.String `gorm:"size:100" json:"email"`
	Name      null.String `gorm:"size:80" json:"name"`
	FirstName null.String `gorm:"size:50" json:"firstname"`
	LastName  null.String `gorm:"size:50" json:"lastname"`
	Gender    null.String `gorm:"size:20" json:"gender"`
	Picture   null.String `json:"picture"` // user profile photo url
	Birthday  null.String `json:"birthday"`
}

OAuthAccount ...

type PayByCardTokenDonation

type PayByCardTokenDonation struct {
	TappayResp
	Amount      uint       `gorm:"not null;index:idx_pay_by_card_token_donations_amount" json:"amount"`
	CreatedAt   time.Time  `json:"created_at"`
	Currency    string     `gorm:"type:varchar(3);default:'TWD';not null" json:"currency"`
	DeletedAt   *time.Time `json:"deleted_at"`
	Details     string     `gorm:"type:varchar(50);not null" json:"details"`
	ID          uint       `gorm:"primary_key" json:"id"`
	MerchantID  string     `gorm:"type:varchar(30);not null" json:"merchant_id"`
	OrderNumber string     `gorm:"type:varchar(50);not null" json:"order_number"`
	PeriodicID  uint       `gorm:"not null;index:idx_pay_by_card_token_donations_periodic_id" json:"periodic_id"`
	Status      string     `gorm:"type:ENUM('paying','paid','fail');not null" json:"status"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

type PayByOtherMethodDonation

type PayByOtherMethodDonation struct {
	Address     string     `gorm:"type:varchar(100)" json:"address"`
	Amount      uint       `gorm:"type:int(10) unsigned;index:idx_pay_by_other_donations_amount" json:"amount"`
	CreatedAt   time.Time  `json:"created_at"`
	Currency    string     `gorm:"type:char(3);default:'TWD';not null" json:"currency"`
	DeletedAt   *time.Time `json:"deleted_at"`
	Details     string     `gorm:"type:varchar(50);not null" json:"details"`
	Email       string     `gorm:"type:varchar(100);not null" json:"email"`
	ID          uint       `gorm:"primary_key" json:"id"`
	MerchantID  string     `gorm:"type:varchar(30);not null" json:"merchant_id"`
	Name        string     `gorm:"type:varchar(30)" json:"name"`
	NationalID  string     `gorm:"type:varchar(20)" json:"national_id"`
	Notes       string     `gorm:"type:varchar(100)" json:"notes"`
	OrderNumber string     `gorm:"type:varchar(50);not null" json:"order_number"`
	PayMethod   string     `gorm:"type:varchar(50);not null;index:idx_pay_by_other_donations_pay_method" json:"pay_method"`
	PhoneNumber string     `gorm:"type:varchar(20)" json:"phone_number"`
	SendReceipt string     `gorm:"type:ENUM('no', 'yearly', 'monthly');default:'yearly'" json:"send_receipt"`
	UpdatedAt   time.Time  `json:"updated_at"`
	UserID      uint       `gorm:"type:int(10) unsigned;not null" json:"user_id"`
	ZipCode     string     `gorm:"type:varchar(10)" json:"zip_code"`
}

type PayByPrimeDonation

type PayByPrimeDonation struct {
	CardInfo
	Cardholder
	TappayResp
	Amount      uint       `gorm:"not null" json:"amount"`
	CreatedAt   time.Time  `json:"created_at"`
	Currency    string     `gorm:"type:varchar(3);default:'TWD';not null" json:"currency"`
	DeletedAt   *time.Time `json:"deleted_at"`
	Details     string     `gorm:"type:varchar(50);not null" json:"details"`
	ID          uint       `gorm:"primary_key" json:"id"`
	MerchantID  string     `gorm:"type:varchar(30);not null" json:"merchant_id"`
	Notes       string     `gorm:"type:varchar(100)" json:"notes"`
	OrderNumber string     `gorm:"type:varchar(50);not null" json:"order_number"`
	PayMethod   string     `` /* 153-byte string literal not displayed */
	SendReceipt string     `gorm:"type:ENUM('no', 'yearly', 'monthly');default:'yearly'" json:"send_receipt"`
	Status      string     `gorm:"type:ENUM('paying','paid','fail');not null" json:"status"`
	UpdatedAt   time.Time  `json:"updated_at"`
	UserID      uint       `gorm:"type:int(10);unsigned;not null" json:"user_id"`
	IsAnonymous null.Bool  `gorm:"type:tinyint(1);default:0" json:"is_anonymous"`
}

type PeriodicDonation

type PeriodicDonation struct {
	Cardholder
	CardInfo
	Amount        uint       `gorm:"type:int(10) unsigned;not null;index:idx_periodic_donations_amount" json:"amount"`
	CardKey       string     `gorm:"type:tinyblob" json:"card_key"`
	CardToken     string     `gorm:"type:tinyblob" json:"card_token"`
	CreatedAt     time.Time  `json:"created_at"`
	Currency      string     `gorm:"type:varchar(3);default:'TWD';not null" json:"currency"`
	DeletedAt     *time.Time `json:"deleted_at"`
	Details       string     `gorm:"type:varchar(50);not null" json:"details"`
	Frequency     string     `gorm:"type:ENUM('monthly', 'yearly');default:'monthly'" json:"frequency"`
	ID            uint       `gorm:"primary_key" json:"id"`
	LastSuccessAt null.Time  `json:"last_success_at"`
	MaxPaidTimes  uint       `json:"max_paid_times" gorm:"type:int;not null;default:2147483647"`
	Notes         string     `gorm:"type:varchar(100)" json:"notes"`
	OrderNumber   string     `gorm:"type:varchar(50);not null" json:"order_number"`
	SendReceipt   string     `gorm:"type:ENUM('no', 'yearly');default:'yearly'" json:"send_receipt"`
	Status        string     `gorm:"type:ENUM('to_pay','paying','paid','fail','stopped','invalid');not null" json:"status"`
	ToFeedback    null.Bool  `gorm:"type:tinyint(1);default:1" json:"to_feedback"`
	UpdatedAt     time.Time  `json:"updated_at"`
	UserID        uint       `gorm:"type:int(10) unsigned;not null" json:"user_id"`
	IsAnonymous   null.Bool  `gorm:"type:tinyint(1);default:0" json:"is_anonymous"`
}

type Post

type Post struct {
	ID                         bson.ObjectId   `bson:"_id" json:"id"`
	Slug                       string          `bson:"slug" json:"slug"`
	Name                       string          `bson:"name" json:"name"`
	Title                      string          `bson:"title" json:"title"`
	Subtitle                   string          `bson:"subtitle" json:"subtitle"`
	State                      string          `bson:"state" json:"state"`
	HeroImage                  *Image          `bson:"-" json:"hero_image,omitempty"`
	HeroImageOrigin            bson.ObjectId   `bson:"heroImage,omitempty" json:"-"`
	HeroImageSize              string          `bson:"heroImageSize" json:"hero_image_size"`
	LeadingImagePortrait       *Image          `bson:"-" json:"leading_image_portrait,omitempty"`
	LeadingImagePortraitOrigin bson.ObjectId   `bson:"leading_image_portrait,omitempty" json:"-"`
	LeadingImageDecription     string          `bson:"leading_image_description" json:"leading_image_description"`
	Brief                      *ContentBody    `bson:"brief,omitempty" json:"brief,omitempty"`
	Categories                 []Category      `bson:"-" json:"categories,omitempty"`
	CategoriesOrigin           []bson.ObjectId `bson:"categories,omitempty" json:"-"`
	Style                      string          `bson:"style" json:"style"`
	Theme                      *Theme          `bson:"-" json:"theme"`
	ThemeOrigin                bson.ObjectId   `bson:"theme,omitempty" json:"-"`
	Copyright                  string          `bson:"copyright" json:"copyright"`
	Tags                       []Tag           `bson:"-" json:"tags,omitempty"`
	TagsOrigin                 []bson.ObjectId `bson:"tags,omitempty" json:"-"`
	OgTitle                    string          `bson:"og_title" json:"og_title"`
	OgDescription              string          `bson:"og_description" json:"og_description"`
	OgImage                    *Image          `bson:"-" json:"og_image,omitempty"`
	OgImageOrigin              bson.ObjectId   `bson:"og_image,omitempty" json:"-"`
	IsFeatured                 bool            `bson:"isFeatured" json:"is_featured"`
	Topic                      *Topic          `bson:"-" json:"topics,omitempty"`
	TopicOrigin                bson.ObjectId   `bson:"topics,omitempty" json:"-"`
	Writters                   []Author        `bson:"-" json:"writters,omitempty"`
	WrittersOrigin             []bson.ObjectId `bson:"writters,omitempty" json:"-"`
	Photographers              []Author        `bson:"-" json:"photographers,omitempty"`
	PhotographersOrigin        []bson.ObjectId `bson:"photographers,omitempty" json:"-"`
	Designers                  []Author        `bson:"-" json:"designers,omitempty"`
	DesignersOrigin            []bson.ObjectId `bson:"designers,omitempty" json:"-"`
	Engineers                  []Author        `bson:"-" json:"engineers,omitempty"`
	EngineersOrigin            []bson.ObjectId `bson:"engineers,omitempty" json:"-"`
	ExtendByline               string          `bson:"extend_byline" json:"extend_byline"`
	LeadingVideo               *Video          `bson:"-" json:"leading_video,omitempty"`
	LeadingVideoOrigin         bson.ObjectId   `bson:"leading_video,omitempty" json:"-"`
	Content                    *ContentBody    `bson:"content,omitempty" json:"content,omitempty"`
	Relateds                   []Post          `bson:"-" json:"relateds,omitempty"`
	RelatedsOrigin             []bson.ObjectId `bson:"relateds,omitempty" json:"-"`
	PublishedDate              time.Time       `bson:"publishedDate" json:"published_date"`
	UpdatedAt                  time.Time       `bson:"updatedAt" json:"updated_at"`
	Full                       bool            `bson:"-" json:"full"`
}

Post ...

func (*Post) GetEmbeddedAsset

func (pm *Post) GetEmbeddedAsset(key string) []bson.ObjectId

GetEmbeddedAsset - `Post` implements this method to become a `NewsEntity`

func (*Post) SetEmbeddedAsset

func (pm *Post) SetEmbeddedAsset(key string, asset interface{})

SetEmbeddedAsset - `Post` implements this method to become a `NewsEntity`

type Query

type Query interface {
	UnmarshalQueryString(string) error
}

Query is an interface which defines the UmarshalQueryString method.

type Registration

type Registration struct {
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	DeletedAt     *time.Time `json:"deleted_at"`
	Service       Service
	ServiceID     uint   `gorm:"primary_key" json:"service_id"`
	Email         string `gorm:"primary_key;size:100" json:"email"`
	User          User
	UserID        uint   `gorm:"default:0" json:"user_id"`
	Active        bool   `gorm:"default:0" json:"active"`
	ActivateToken string `gorm:"size:20" json:"active_token"`
}

Registration this is bookmakrs table description

type RegistrationJSON

type RegistrationJSON struct {
	Email         string `json:"email" binding:"required"`
	UserID        string `json:"uid"`
	Active        bool   `json:"active"`
	ActivateToken string `json:"active_token"`
}

RegistrationJSON this is POST data in json format

type ReporterAccount

type ReporterAccount struct {
	UserID        uint       `json:"user_id"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	DeletedAt     *time.Time `json:"deleted_at"`
	ID            uint       `gorm:"primary_key" json:"id"`
	Email         string     `gorm:"size:100;unique_index;not null" json:"email"`
	ActivateToken string     `gorm:"size:50" json:"activate_token"`
	ActExpTime    time.Time  `json:"-"`
}

ReporterAccount ...

type ResizedTargets

type ResizedTargets struct {
	Mobile  ImageAsset `bson:"mobile" json:"mobile"`
	Tiny    ImageAsset `bson:"tiny" json:"tiny"`
	Desktop ImageAsset `bson:"desktop" json:"desktop"`
	Tablet  ImageAsset `bson:"tablet" json:"tablet"`
	W400    ImageAsset `bson:"w400" json:"w400"`
}

ResizedTargets ...

type Service

type Service struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at"`
	Name      string     `gorm:"size:100;unique_index;not null" json:"name"`
}

Service this is service table description

type ServiceJSON

type ServiceJSON struct {
	ID   uint   `json:"id"`
	Name string `json:"name" binding:"required"`
}

ServiceJSON ...

type Tag

type Tag struct {
	ID   bson.ObjectId `bson:"_id" json:"id"`
	Name string        `bson:"name" json:"name"`
}

Tag ...

type TappayResp

type TappayResp struct {
	Acquirer                 string      `gorm:"type:varchar(50);not null" json:"acquirer"`
	AuthCode                 string      `gorm:"type:varchar(6);not null" json:"auth_code"`
	BankResultCode           null.String `gorm:"type:varchar(50)" json:"bank_result_code"`
	BankResultMsg            null.String `gorm:"type:varchar(50)" json:"bank_result_msg"`
	BankTransactionEndTime   null.Time   `json:"bank_transaction_end_time"`
	BankTransactionID        string      `gorm:"type:varchar(50);not null" json:"bank_transaction_id"`
	BankTransactionStartTime null.Time   `json:"bank_transaction_start_time"`
	Msg                      string      `gorm:"type:varchar(100);not null" json:"msg"`
	RecTradeID               string      `gorm:"type:varchar(20);not null" json:"rec_trade_id"`
	TappayApiStatus          null.Int    `json:"tappay_api_status"`
	TappayRecordStatus       null.Int    `json:"tappay_record_status"`
	TransactionTime          null.Time   `json:"transaction_time"`
}

type Theme

type Theme struct {
	ID              bson.ObjectId `bson:"_id" json:"id"`
	Name            string        `bson:"name" json:"name"`
	TitlePosition   string        `bson:"title_position" json:"title_position"`
	HeaderPosition  string        `bson:"header_position" json:"header_position"`
	TitleColor      string        `bson:"title_color" json:"title_color"`
	SubtitleColor   string        `bson:"subtitle_color" json:"subtitle_color"`
	TopicColor      string        `bson:"topic_color" json:"topic_color"`
	FontColor       string        `bson:"font_color" json:"font_color"`
	BackgroundColor string        `bson:"bg_color" json:"bg_color"`
	FooterBGColor   string        `bson:"footer_bg_color" json:"footer_bg_color"`
	LogoColor       string        `bson:"logo_color" json:"logo_color"`
}

Theme ...

type Topic

type Topic struct {
	ID                         bson.ObjectId   `json:"id" bson:"_id"`
	Slug                       string          `bson:"slug" json:"slug"`
	Name                       string          `bson:"name" json:"name"`
	TopicName                  string          `bson:"topic_name" json:"topic_name"`
	Title                      string          `bson:"title" json:"title"`
	TitlePosition              string          `bson:"title_position" json:"title_position"`
	Subtitle                   string          `bson:"subtitle" json:"subtitle"`
	Headline                   string          `bson:"headline" json:"headline"`
	State                      string          `bson:"state" json:"state"`
	Description                *ContentBody    `bson:"description,omitempty" json:"description,omitempty"`
	TeamDescription            *ContentBody    `bson:"team_description,omitempty" json:"team_description,omitempty"`
	Relateds                   []Post          `bson:"-" json:"relateds,omitempty"`
	RelatedsOrigin             []bson.ObjectId `bson:"relateds,omitempty" json:"-"`
	RelatedsFormat             string          `bson:"relateds_format" json:"relateds_format"`
	RelatedsBackground         string          `bson:"relateds_background" json:"relateds_background"`
	LeadingImage               *Image          `bson:"-" json:"leading_image,omitempty"`
	LeadingImageOrigin         bson.ObjectId   `bson:"leading_image,omitempty" json:"-"`
	LeadingImagePortrait       *Image          `bson:"-" json:"leading_image_portrait,omitempty"`
	LeadingImagePortraitOrigin bson.ObjectId   `bson:"leading_image_portrait,omitempty" json:"-"`
	LeadingVideo               *Video          `bson:"-" json:"leading_video,omitempty"`
	LeadingVideoOrigin         bson.ObjectId   `bson:"leading_video,omitempty" json:"-"`
	OgTitle                    string          `bson:"og_title" json:"og_title"`
	OgDescription              string          `bson:"og_description" json:"og_description"`
	OgImage                    *Image          `bson:"-" json:"og_image,omitempty"`
	OgImageOrigin              bson.ObjectId   `bson:"og_image,omitempty" json:"-"`
	PublishedDate              time.Time       `bson:"publishedDate" json:"published_date"`
	UpdatedAt                  time.Time       `bson:"updatedAt" json:"updated_at"`
	Full                       bool            `bson:"-" json:"full"`
}

Topic ...

func (*Topic) GetEmbeddedAsset

func (t *Topic) GetEmbeddedAsset(key string) []bson.ObjectId

GetEmbeddedAsset - `Topic` implements this method to become a `NewsEntity`

func (*Topic) SetEmbeddedAsset

func (t *Topic) SetEmbeddedAsset(key string, asset interface{})

SetEmbeddedAsset - `Topic` implements this method to become a `NewsEntity`

type User

type User struct {
	ID               uint            `gorm:"primary_key" json:"id"`
	CreatedAt        time.Time       `json:"created_at"`
	UpdatedAt        time.Time       `json:"updated_at"`
	DeletedAt        *time.Time      `json:"deleted_at"`
	OAuthAccounts    []OAuthAccount  `gorm:"ForeignKey:UserID"` // a user has multiple oauth accounts //
	ReporterAccount  ReporterAccount `gorm:"ForeignKey:UserID"`
	Bookmarks        []Bookmark      `gorm:"many2many:users_bookmarks;"`
	Email            null.String     `gorm:"size:100" json:"email"`
	FirstName        null.String     `gorm:"size:50" json:"firstname"`
	LastName         null.String     `gorm:"size:50" json:"lastname"`
	SecurityID       null.String     `gorm:"size:20" json:"security_id"`
	PassportID       null.String     `gorm:"size:30" json:"passport_id"`
	City             null.String     `gorm:"size:45" json:"city"`
	State            null.String     `gorm:"size:45" json:"state"`
	Country          null.String     `gorm:"size:45" json:"country"`
	Zip              null.String     `gorm:"size:20" json:"zip"`
	Address          null.String     `json:"address"`
	Phone            null.String     `gorm:"size:20" json:"phone"`
	Privilege        int             `gorm:"type:int(5);not null" json:"privilege"`
	RegistrationDate null.Time       `json:"registration_date"`
	Birthday         null.Time       `json:"birthday"`
	Gender           null.String     `gorm:"size:2" json:"gender"`     // e.g., "M", "F" ...
	Education        null.String     `gorm:"size:20" json:"education"` // e.g., "High School"
	EnableEmail      int             `gorm:"type:int(5);size:2" json:"enable_email"`
}

User ...

type UsersBookmarks

type UsersBookmarks struct {
	gorm.JoinTableHandler
	UserID     int
	BookmarkID int
	CreatedAt  time.Time
}

UsersBookmarks users and bookmarks many-to-many table

func (*UsersBookmarks) Add

func (*UsersBookmarks) Add(handler gorm.JoinTableHandlerInterface, db *gorm.DB, foreignValue interface{}, associationValue interface{}) error

Add - implement gorm.JoinTableHandlerInterface Add method Use gorm to create the record automatically populated with CreatedAt

type Video

type Video struct {
	ID       bson.ObjectId `json:"id" bson:"_id"`
	Title    string        `json:"title"`
	Filetype string        `json:"filetype"`
	Size     uint          `json:"size"`
	URL      string        `json:"url"`
}

Video is used to return in response

type WebPushSubscription

type WebPushSubscription struct {
	ID             uint       `gorm:"primary_key" json:"id"`
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
	Endpoint       string     `gorm:"unique" json:"endpoint"`
	Crc32Endpoint  uint32     `gorm:"index;" json:"crc32_endpoint"`
	Keys           string     `json:"-"`
	ExpirationTime *time.Time `json:"expiration_time"`
	UserID         *uint      `json:"user_id"`
}

TODO add foreign key to bind web push subscription with user later WebPushSubscription - a data model which is used by storage to communicate with persistent database

func (*WebPushSubscription) SetExpirationTime

func (wpSub *WebPushSubscription) SetExpirationTime(expireTime int64)

SetExpirationTime - set the pointer of expireTime into WebPushSubscription struct. The reason why we set the pointer, not the value, into struct is because we want to remain the NULL(nil) value if expireTime is not provided.

func (*WebPushSubscription) SetUserID

func (wpSub *WebPushSubscription) SetUserID(userID uint)

SetUserID - set the pointer of userID into WebPushSubscription struct

func (WebPushSubscription) TableName

func (WebPushSubscription) TableName() string

set WebPushSubscription's table name to be `web_push_subs`

Jump to

Keyboard shortcuts

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