models

package
v0.0.0-...-2d91a95 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrDatabase = -1
	ErrSystem   = -2
	ErrDupRows  = -3
	ErrNotFound = -4
)

Predefined model error codes.

Variables

View Source
var ItemFields = []string{
	"id",
	"link",
	"title",
	"meta",
	"attributes",
	"postedAt",
	"updatedAt",
	"source",
}

ItemFields is a global fields of item

Functions

This section is empty.

Types

type Address

type Address struct {
	Country    string     `bson:"country,omitempty" json:"country,omitempty"`
	State      string     `bson:"state,omitempty" json:"state,omitempty"`
	City       string     `bson:"city,omitempty" json:"city,omitempty"`
	Coordinate Coordinate `bson:"coordinate,omitempty" json:"coordinate,omitempty"`
}

Address is a struct for ...

type AttributeKeyValInt

type AttributeKeyValInt struct {
	Value        float32 `bson:"value,omitempty" json:"value,omitempty"`
	Denomination string  `bson:"denomination,omitempty" json:"denomination,omitempty"`
}

AttributeKeyValInt a struct for ...

type Attributes

type Attributes struct {
	SaleAttribute map[string]interface{} `bson:"saleAttribute,omitempty" json:"saleAttribute,omitempty"`
	Spesification map[string]interface{} `bson:"spesification,omitempty" json:"spesification,omitempty"`
}

Attributes a struct for ...

type Category

type Category struct {
	ID                  bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Node                int           `bson:"node" json:"node"`
	ParentNode          int           `bson:"parentNode" json:"parentNode"`
	Sort                int           `bson:"sort" json:"sort"`
	Name                string        `bson:"name" json:"name"`
	Keyword             string        `bson:"keyword" json:"keyword"`
	MetaTitle           string        `bson:"metaTitle" json:"metaTitle"`
	MetaDescription     string        `bson:"metaDescription" json:"metaDescription"`
	LanguageCulture     string        `bson:"languageCulture" json:"languageCulture"`
	LanguageCultureSort int           `bson:"languageCultureSort" json:"languageCultureSort"`
	Status              int           `bson:"status" json:"status"`
	CreatedAt           time.Time     `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	UpdatedAt           time.Time     `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	UpdatedBy           bson.ObjectId `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	CreatedBy           bson.ObjectId `bson:"createdBy,omitempty" json:"createdBy,omitempty"`
}

Category is a struct for ...

func (*Category) GetParent

func (cat *Category) GetParent() (res Category, err error)

GetParent a function for add new data category

func (*Category) Insert

func (cat *Category) Insert() (code int, err error)

Insert a function for add new data category

func (*Category) New

func (cat *Category) New()

New is a function for ...

type ChangePassword

type ChangePassword struct {
	ID          bson.ObjectId `form:"id" json:"id" validate:"required;Match(/^\\w{24}$/)"`
	OldPassword string        `form:"oldPassword" json:"oldPassword" validate:"Required"`
	NewPassword string        `form:"newPassword" json:"newPassword" validate:"Required"`
}

ChangePassword definition.

type CodeInfo

type CodeInfo struct {
	Code int    `json:"code"`
	Info string `json:"info"`
}

CodeInfo definiton.

func NewErrorInfo

func NewErrorInfo(info string) *CodeInfo

NewErrorInfo return a CodeInfo represents error.

func NewNormalInfo

func NewNormalInfo(info string) *CodeInfo

NewNormalInfo return a CodeInfo represents OK.

type Coordinate

type Coordinate struct {
	Latitude  string `bson:"latitude,omitempty" json:"latitude,omitempty"`
	Longitude string `bson:"longitude,omitempty" json:"longitude,omitempty"`
}

Coordinate is a struct for ...

type DefaultProductAttribute

type DefaultProductAttribute struct {
	Brand string `bson:"brand,omitempty" json:"brand,omitempty"`
	Type  string `bson:"type,omitempty" json:"type,omitempty"`
}

DefaultProductAttribute is a struct for ...

type Error

type Error struct {
	UserMessage     string
	InternalMessage string
	StatusCode      int
	Code            int
	MoreInfo        string
}

Error is a struct for ...

type GlobalInformation

type GlobalInformation struct {
	ID        string `form:"id"        validate:"required;Match(/^\\w{24}$/)"`
	Username  string `form:"username"  validate:"required;MinSize(6);MaxSize(30)"`
	Mobile    string `form:"mobile"    validate:"required;Match(/^\\d{12}/)"`
	BirthDate string `form:"birthdate" validate:"required;Match(/^\\d{4}-\\d{2}-\\d{2}$/)"`
	Gender    int    `form:"gender"    validate:"required;Numeric;Range(0,2)"`
}

GlobalInformation definition.

type Item

type Item struct {
	ID          bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Link        string        `bson:"link,omitempty" json:"link,omitempty"`
	Name        string        `bson:"name,omitempty" json:"name,omitempty"`
	Description string        `bson:"description,omitempty" json:"description,omitempty"`
	Images      []string      `bson:"images,omitempty" json:"images,omitempty"`
	Attributes  interface{}   `bson:"attributes,omitempty" json:"attributes,omitempty"`
	Address     Address       `bson:"address,omitempty" json:"address,omitempty"`
	Categories  []string      `bson:"categories,omitempty" json:"categories,omitempty"`
	Keywords    string        `bson:"keywords,omitempty" json:"keywords,omitempty"`
	User        UserBase      `bson:"user,omitempty" json:"user,omitempty"`
	Status      int           `bson:"status" json:"status"`
	PostedAt    time.Time     `bson:"postedAt,omitempty" json:"postedAt,omitempty"`
	CreatedAt   time.Time     `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	UpdatedAt   time.Time     `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	UpdatedBy   bson.ObjectId `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	CreatedBy   bson.ObjectId `bson:"createdBy,omitempty" json:"createdBy,omitempty"`
}

Item is a struct for ...

func (*Item) GetShortDescription

func (i *Item) GetShortDescription() string

GetShortDescription is a function for ...

func (*Item) Insert

func (i *Item) Insert() (code int, err error)

Insert is a function for insert document to collection.

func (*Item) New

func (i *Item) New()

New is a function for ...

func (*Item) SetAttributes

func (i *Item) SetAttributes(attr interface{})

SetAttributes is a function for ...

func (*Item) TargetName

func (i *Item) TargetName() string

TargetName is a function for ...

type Items

type Items []map[string]interface{}

Items is a struct for ...

func (Items) Len

func (s Items) Len() int

func (Items) Less

func (s Items) Less(i, j int) bool

func (Items) Swap

func (s Items) Swap(i, j int)

type JwtCustomClaims

type JwtCustomClaims struct {
	/*	Name  string `json:"name" xml:"name"`
		Email string `json:"email" xml:"email"`
		Role  string `json:"role" xml:"role"`
	*/
	Identity string `json:"identity" xml:"identity"`
	jwt.StandardClaims
}

JwtCustomClaims are custom claims extending default ones.

type Location

type Location struct {
	ID                bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Node              int           `bson:"node" json:"node"`
	ParentNode        int           `bson:"parentNode" json:"parentNode"`
	Sort              int           `bson:"sort" json:"sort"`
	Type              string        `bson:"type" json:"type"` // Country | State | City | - | Village
	Name              string        `bson:"name" json:"name"`
	Keyword           string        `bson:"keyword" json:"keyword"`
	MetaTitle         string        `bson:"metaTitle" json:"metaTitle"`
	MetaDescription   string        `bson:"metaDescription" json:"metaDescription"`
	InternationalName string        `bson:"internationalName" json:"internationalName"`
	Attributes        interface{}   `bson:"attributes" json:"attributes"`
	Status            int           `bson:"status" json:"status"`
	CreatedAt         time.Time     `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	UpdatedAt         time.Time     `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	UpdatedBy         bson.ObjectId `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	CreatedBy         bson.ObjectId `bson:"createdBy,omitempty" json:"createdBy,omitempty"`
}

Location is a struct for ...

func (*Location) Insert

func (loc *Location) Insert() (code int, err error)

Insert a function for add new data category

func (*Location) New

func (loc *Location) New()

New is a function for ...

type LoginInfo

type LoginInfo struct {
	Code     int   `json:"code"`
	UserInfo *User `json:"user"`
}

LoginInfo definition.

type Logout

type Logout struct {
	ID string `form:"id" json:"id" validate:"required;Match(/^\\w{24}$/)"`
}

Logout defintion.

type MotorCycleSpesification

type MotorCycleSpesification struct {
	DefaultProductAttribute
	CreatedAt      time.Time          `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	Fuel           string             `bson:"fuel,omitempty" json:"fuel,omitempty"`
	EngineCapacity AttributeKeyValInt `bson:"engineCapacity,omitempty" json:"engineCapacity,omitempty"`
	// contains filtered or unexported fields
}

MotorCycleSpesification a struct for ...

type Profile

type Profile struct {
	FirstName    string      `bson:"firstName,omitempty" json:"firstName,omitempty"`
	LastName     string      `bson:"lastName,omitempty" json:"lastName,omitempty"`
	Contacts     interface{} `bson:"contacts,omitempty" json:"contacts,omitempty"`
	PhotoProfile string      `bson:"photoProfile,omitempty" json:"photoProfile,omitempty"`
}

Profile is a struct for ...

func (*Profile) New

func (p *Profile) New(name string)

New alloc and initialize a user.

type Result

type Result struct {
	Errors []Error `json:"errors"`
}

Result is a struct for ...

type SaleAttribute

type SaleAttribute struct {
	Price    string `bson:"price,omitempty" json:"price,omitempty"`
	Currency string `bson:"currency,omitempty" json:"currency,omitempty"`
}

SaleAttribute is a struct for ...

type Search struct {
	Query     string            `json:"q" form:"q" query:"q"`
	Filter    map[string]string `json:"filter" form:"filter" query:"filter"`          //attributes[...][...],
	Sort      string            `json:"sort" form:"sort" query:"sort"`                //sort[...][...],
	Fields    string            `json:"fields" form:"fields" query:"fields"`          //sort[...][...],
	Paging    map[string]int    `json:"paging" form:"paging" query:"paging"`          //offset=10&limit=5
	Algorithm map[string]string `json:"algorithm" form:"algorithm" query:"algorithm"` // tsukamoto
}

Search is a struct for ...

func (*Search) Find

func (s *Search) Find() (result map[string]interface{}, err error)

Find is a func for ...

func (*Search) FindSame

func (s *Search) FindSame() (items Items, err error)

FindSame :

func (*Search) Init

func (s *Search) Init()

Init for Search

type Target

type Target struct {
	ID        bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Domain    string        `bson:"domain,omitempty" json:"domain,omitempty"`
	Name      string        `bson:"name,omitempty" json:"name,omitempty"`
	Type      string        `bson:"type" json:"type"` // ecommerce | marketplace | news
	Status    int           `bson:"status" json:"status"`
	CreatedAt time.Time     `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	UpdatedAt time.Time     `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	UpdatedBy bson.ObjectId `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	CreatedBy bson.ObjectId `bson:"createdBy,omitempty" json:"createdBy,omitempty"`
}

Target is a struct for..

func (*Target) Insert

func (t *Target) Insert() (code int, err error)

Insert is a function for insert document to collection.

func (*Target) New

func (t *Target) New()

New is a function for ...

type Uploads

type Uploads struct {
	ID string `form:"id"  json:"id" validate:"required;Match(/^\\w{24}$/)"`
}

Uploads definition.

type User

type User struct {
	ID           bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Role         string        `bson:"role,omitempty" json:"role,omitempty"`
	UserName     string        `bson:"userName,omitempty" json:"userName,omitempty"`
	Email        string        `bson:"email,omitempty" json:"email,omitempty"`
	MobilePhone  string        `bson:"mobilePhone,omitempty" json:"mobilePhone,omitempty"`
	Password     string        `bson:"password,omitempty" json:"password,omitempty"`
	Salt         string        `bson:"salt,omitempty" json:"salt,omitempty"`
	LoginHistory interface{}   `bson:"loginHistory,omitempty" json:"loginHistory,omitempty"`
	History      interface{}   `bson:"history,omitempty" json:"history,omitempty"`
	Status       int           `bson:"status" json:"status"`
	CreatedAt    time.Time     `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	UpdatedAt    time.Time     `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	UpdatedBy    bson.ObjectId `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	CreatedBy    bson.ObjectId `bson:"createdBy,omitempty" json:"createdBy,omitempty"`
	Profile      Profile       `bson:"profile,omitempty" json:"profile,omitempty"`
}

User is a struct for ...

func (*User) AuthFind

func (u *User) AuthFind(id string) (code int, err error)

AuthFind query a document according to input email.

func (*User) ChangePass

func (u *User) ChangePass(id, oldPass, newPass string) (code int, err error)

ChangePass update password and salt information according to input id.

func (*User) CheckPass

func (u *User) CheckPass(pass string) (ok bool, err error)

CheckPass compare input password.

func (*User) ClearPass

func (u *User) ClearPass()

ClearPass clear password information.

func (*User) FindByEmail

func (u *User) FindByEmail(email string) (code int, err error)

FindByEmail query a document according to input email.

func (*User) FindByID

func (u *User) FindByID(id string) (code int, err error)

FindByID query a document according to input id.

func (*User) Insert

func (u *User) Insert() (code int, err error)

Insert is a function for insert document to collection.

func (*User) New

func (u *User) New()

New is a function for ...

type UserAuth

type UserAuth struct {
	AccountID string `json:"accountId" form:"accountId" xml:"accountId" validate:"required,email"`
	Password  string `json:"password" form:"password" xml:"password" validate:"required,min=6"`
}

UserAuth is a models ...

func (*UserAuth) UserClaimsIdentity

func (ua *UserAuth) UserClaimsIdentity() (t string, err error)

UserClaimsIdentity is a function...

type UserBase

type UserBase struct {
	Link         string      `bson:"link,omitempty" json:"link,omitempty"`
	Name         string      `bson:"name,omitempty" json:"name,omitempty"`
	Contacts     interface{} `bson:"contacts,omitempty" json:"contacts,omitempty"`
	PhotoProfile string      `bson:"photoProfile,omitempty" json:"photoProfile,omitempty"`
	Address      Address     `bson:"address,omitempty" json:"address,omitempty"`
}

UserBase is a struct for ...

type UserRegister

type UserRegister struct {
	Email           string `form:"email" json:"email" validate:"required,email"`
	UserName        string `form:"userName" json:"userName" validate:"required,min=4,max=30"`
	Password        string `form:"password" json:"password" validate:"required,min=6,max=30"`
	ConfirmPassword string `form:"confirmPassword" json:"confirmPassword" validate:"required,min=6,max=30,eqfield=Password"`
}

UserRegister definition.

func (*UserRegister) Save

func (r *UserRegister) Save() (code int, err error)

Save alloc and initialize a user.

Jump to

Keyboard shortcuts

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