models

package
v0.0.0-...-a33bf99 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommentCollectionName = "comment"

	CommentTypeQuestion = "QUESTION"
	CommentTypePublic   = "PUBLIC"
	CommentTypeFeedback = "FEEDBACK"
	CommentTypeInternal = "INTERNAL"
)
View Source
const (
	ExtendFieldInputTypeText     = "TEXT"
	ExtendFieldInputTypeTextarea = "TEXTAREA"
	ExtendFieldInputTypeSelect   = "SELECT"
	ExtendFieldInputTypeCheckbox = "CHECKBOX"
)
View Source
const (
	FocusCollectionName = "focus"

	FocusStatusPending = "PENDING"
	FocusStatusHandled = "HANDLED"
)
View Source
const (
	PriorityNon    TypePriority = ""
	PriorityLow    TypePriority = "1"
	PriorityNormal TypePriority = "2"
	PriorityHign   TypePriority = "3"
	PriorityUrgent TypePriority = "4"

	PriorityNonStr    = ""
	PriorityLowStr    = "LOW"
	PriorityNormalStr = "NORMAL"
	PriorityHignStr   = "HIGH"
	PriorityUrgentStr = "URGENT"
)
View Source
const (
	ResourceTypeTicket  = "TICKET"
	ResourceTypeComment = "COMMENT"
)
View Source
const (
	TicketCollectionName = "ticket"

	TicketStatusPending     = "PENDING"
	TicketStatusReplied     = "REPLIED"
	TicketStatusResubmitted = "RESUBMITTED"
	TicketStatusSolved      = "SOLVED"
)
View Source
const (
	UserImportanceNon       TypeUserImportance = "0"
	UserImportanceNormal    TypeUserImportance = "1"
	UserImportanceImportant TypeUserImportance = "2"
	UserImportanceVIP       TypeUserImportance = "3"

	UserImportanceNonStr       = "NON"
	UserImportanceNormalStr    = "NORMAL"
	UserImportanceImportantStr = "IMPORTANT"
	UserImportanceVIPStr       = "VIP"
)
View Source
const (
	AutomationCollectionName = "automation"
)
View Source
const (
	BrandCollectionName = "brand"
)
View Source
const (
	FileCollectionName = "file"
)
View Source
const (
	UserCollectionName = "user"
)

Variables

View Source
var (
	Now = time.Now

	NewId = mgoutils.NewId

	IsEmptyId = mgoutils.IsEmptyObjectId
)
View Source
var (
	EmptyComment = &Comment{}
)
View Source
var (
	EmptyFocus = &Focus{}
)
View Source
var (
	EmptyTicket = &Ticket{}
)
View Source
var (
	EmptyUser = &User{}
)
View Source
var (
	MgoIndexes = map[string][]mgo.Index{
		BrandCollectionName: []mgo.Index{
			mgo.Index{
				Key:    []string{"on"},
				Unique: true,
			},
		},
		UserCollectionName: []mgo.Index{
			mgo.Index{
				Key:    []string{"channel.name", "channel.id"},
				Unique: true,
			},
		},
		TicketCollectionName: []mgo.Index{
			mgo.Index{
				Key:    []string{"channel.name", "channel.id"},
				Unique: true,
			},
		},
	}
)

Functions

func Count

func Count(collName string, query map[string]interface{}) (int, error)

func EnsureIndexes

func EnsureIndexes() error

func FindAll

func FindAll(collName string, query, projection map[string]interface{}, sort []string, result interface{}) error

func FindAndModify

func FindAndModify(collName string, query, projection, change map[string]interface{}, result interface{}) error

func FindById

func FindById(collName string, id interface{}, projection map[string]interface{}, result interface{}) error

func FindOne

func FindOne(collName string, query, projection map[string]interface{}, result interface{}) error

func FindOrInsert

func FindOrInsert(collName string, query map[string]interface{}, doc, result interface{}) (bool, error)

func Insert

func Insert(collName string, doc ...interface{}) error

func List

func List(collName string, query, projection map[string]interface{}, start, limit int, sort []string, result interface{}) error

func RemoveAll

func RemoveAll(collName string, query map[string]interface{}) (int, error)

func RemoveById

func RemoveById(collName string, id interface{}) error

func RemoveOne

func RemoveOne(collName string, query map[string]interface{}) error

func SetStorage

func SetStorage(stg *mgoutils.MgoPool)

func UpdateAll

func UpdateAll(collName string, query, update map[string]interface{}) (int, error)

func UpdateById

func UpdateById(collName string, id interface{}, change map[string]interface{}) error

func UpdateOne

func UpdateOne(collName string, query, update map[string]interface{}) error

Types

type Automation

type Automation struct {
	Id      bson.ObjectId `json:"id" bson:"_id"`
	Created int64         `json:"created" bson:"created"`
	Updated int64         `json:"updated" bson:"updated"`

	Priority int `json:"priority" bson:"priority"`

	Conditions map[bson.ObjectId][]*AutomationCondition `json:"conditions" bson:"conditions"`
	Actions    []*AutomationAction                      `json:"actions" bson:"actions"`
}

type AutomationAction

type AutomationAction struct {
	Id     bson.ObjectId `json:"id" bson:"_id"`
	Type   string        `json:"type" bson:"type"`
	Target string        `json:"target" bson:"target"`
	ValStr string        `json:"valStr" bson:"valStr"`
}

type AutomationCondition

type AutomationCondition struct {
	Id       bson.ObjectId `json:"id" bson:"_id"`
	Operator string        `json:"operator" bson:"operator"`
	Field    string        `json:"field" bson:"field"`
	ValStr   string        `json:"valStr" bson:"valStr"`
}

type Brand

type Brand struct {
	Id      bson.ObjectId `json:"id" bson:"_id"`
	Created int64         `json:"created" bson:"created"`
	Updated int64         `json:"updated" bson:"updated"`

	Base          BrandBaseInfo         `json:"base" bson:"base"`
	Authorization BrandAutorizationInfo `json:"-" bson:"authorization"`
	PreExtend     BrandPreExtend        `json:"-" bson:"preExtend"`
	On            bool                  `json:"-" bson:"on"`
}

func NewBrand

func NewBrand(name string) *Brand

func (*Brand) FindAndModify

func (this *Brand) FindAndModify(query, change map[string]interface{}) error

func (*Brand) FindOne

func (this *Brand) FindOne(query map[string]interface{}) error

func (*Brand) Insert

func (this *Brand) Insert() error

type BrandAutorizationInfo

type BrandAutorizationInfo struct {
	APIKey string `json:"apiKey" bson:"apiKey"`
}

type BrandBaseInfo

type BrandBaseInfo struct {
	Name string `json:"name" bson:"name"`
}

type BrandPreExtend

type BrandPreExtend struct {
	Ticket []*ExtendField `json:"ticket" bson:"ticket"`
	Client []*ExtendField `json:"client" bson:"client"`
}

type ChannelInfo

type ChannelInfo struct {
	Name string      `json:"name" bson:"name"`
	Id   interface{} `json:"-" bson:"id"`
}

type Comment

type Comment struct {
	Id          bson.ObjectId `json:"id" bson:"_id"`
	TicketId    bson.ObjectId `json:"-" bson:"ticketId"`
	CreatorId   bson.ObjectId `json:"-" bson:"creatorId"`
	Type        string        `json:"type" bson:"type"`
	Content     string        `json:"content" bson:"content"`
	Created     int64         `json:"created" bson:"created"`
	Updated     int64         `json:"updated" bson:"updated"`
	Attachments []*File       `json:"attachmente" bson:"attachments"`
}

func NewComment

func NewComment(ticketId, creatorId bson.ObjectId, typ, content string) *Comment

func (*Comment) FindAll

func (this *Comment) FindAll(query map[string]interface{}, sort []string) ([]*Comment, error)

func (*Comment) FindAndModify

func (this *Comment) FindAndModify(query, change map[string]interface{}) error

func (*Comment) FindById

func (this *Comment) FindById(id interface{}) error

func (*Comment) FindOne

func (this *Comment) FindOne(query map[string]interface{}) error

func (*Comment) Insert

func (this *Comment) Insert() error

type ExtendField

type ExtendField struct {
	Id          bson.ObjectId `json:"id" bson:"_id"`
	Label       string        `json:"label" bson:"label"`
	Description string        `json:"description" bson:"description"`
	Input       string        `json:"input" bson:"input"`
	Options     []string      `json:"options" bson:"options"`
	Created     int64         `json:"created" bson:"created"`
	Updated     int64         `json:"updated" bson:"updated"`
}

func NewExtendField

func NewExtendField() *ExtendField

type File

type File struct {
	Id         bson.ObjectId `json:"id" bson:"_id"`
	IsInternal bool          `json:"isInternal" bson:"isInternal"`
	MimeType   string        `json:"mimeType" bson:"mimeType"`
	FileSize   int64         `json:"fileSize" bson:"fileSize"`
	FileName   string        `json:"fileName" bson:"fileName"`
	FileKey    string        `json:"fileKey" bson:"fileKey"`
	Created    int64         `json:"created" bson:"created"`
}

func NewFile

func NewFile() *File

func (*File) Insert

func (this *File) Insert() error

type Focus

type Focus struct {
	Id       bson.ObjectId `json:"id" bson:"_id"`
	Type     string        `json:"type" bson:"type"`
	Status   string        `json:"status" bson:"status"`
	Priority TypePriority  `json:"priority" bson:"priority"`
	Resource *Resource     `json:"resource" bson:"resource"`
	Message  string        `json:"message" bson:"message"`
	Created  int64         `json:"created" bson:"created"`
	Handled  int64         `json:"handled" bson:"handled"`
	Deadline int64         `json:"deadline" bson:"deadline"`
}

func NewFocus

func NewFocus(typ, message string) *Focus

func (*Focus) Count

func (this *Focus) Count(query map[string]interface{}) (int, error)

func (*Focus) FindAndModify

func (this *Focus) FindAndModify(query, change map[string]interface{}) error

func (*Focus) FindById

func (this *Focus) FindById(id interface{}) error

func (*Focus) Insert

func (this *Focus) Insert() error

func (*Focus) List

func (this *Focus) List(query map[string]interface{}, start, limit int, sort []string) ([]*Focus, error)

func (*Focus) UpdateById

func (this *Focus) UpdateById(id interface{}, change map[string]interface{}) error

type Resource

type Resource struct {
	Type   string        `json:"type" bson:"type"`
	Id     bson.ObjectId `json:"id" bson:"id,omitempty"`
	Parent *Resource     `json:"parent,omitempty" bson:"parent,omitempty"`
}

func NewResource

func NewResource(typ string, id bson.ObjectId, parent *Resource) *Resource

type Ticket

type Ticket struct {
	Id        bson.ObjectId `json:"id" bson:"_id"`
	CreatorId bson.ObjectId `json:"-" bson:"creatorId"`
	Channel   ChannelInfo   `json:"channel" bson:"channel"`

	Subject        string            `json:"subject" bson:"subject"`
	IsPublic       bool              `json:"isPublic" bson:"isPublic"`
	Created        int64             `json:"created" bson:"created"`
	Updated        int64             `json:"updated" bson:"updated"`
	FirstCommented int64             `json:"firstCommented" bson:"firstCommented"`
	Priority       TypePriority      `json:"priority" bson:"priority"`
	Status         string            `json:"status" bson:"status"`
	Rank           int               `json:"rank" bson:"rank"`
	Extend         map[string]string `json:"extend" bson:"extend"`
}

func NewTicket

func NewTicket(creatorId bson.ObjectId) *Ticket

func (*Ticket) Count

func (this *Ticket) Count(query map[string]interface{}) (int, error)

func (*Ticket) FindAndModify

func (this *Ticket) FindAndModify(query, change map[string]interface{}) error

func (*Ticket) FindById

func (this *Ticket) FindById(id interface{}) error

func (*Ticket) Insert

func (this *Ticket) Insert() error

func (*Ticket) List

func (this *Ticket) List(query map[string]interface{}, start, limit int, sort []string) ([]*Ticket, error)

type TypePriority

type TypePriority string

func NewTypePriority

func NewTypePriority(s string) TypePriority

func (*TypePriority) FromOutput

func (this *TypePriority) FromOutput(s string)

func (TypePriority) MarshalJSON

func (this TypePriority) MarshalJSON() ([]byte, error)

func (TypePriority) ToOutput

func (this TypePriority) ToOutput() string

func (*TypePriority) UnmarshalJSON

func (this *TypePriority) UnmarshalJSON(b []byte) error

type TypeUserImportance

type TypeUserImportance string

func NewTypeUserImportance

func NewTypeUserImportance(s string) TypeUserImportance

func (*TypeUserImportance) FromOutput

func (this *TypeUserImportance) FromOutput(s string)

func (TypeUserImportance) MarshalJSON

func (this TypeUserImportance) MarshalJSON() ([]byte, error)

func (TypeUserImportance) ToOutput

func (this TypeUserImportance) ToOutput() string

func (*TypeUserImportance) UnmarshalJSON

func (this *TypeUserImportance) UnmarshalJSON(b []byte) error

type User

type User struct {
	Id      bson.ObjectId `json:"id" bson:"_id"`
	Updated int64         `json:"updated" bson:"updated"`
	Created int64         `json:"created" bson:"created"`

	Login    UserLoginInfo    `json:"-" bson:"login"`
	Channel  ChannelInfo      `json:"-" bson:"channel"`
	Base     UserBaseInfo     `json:"-" bson:"base"`
	Personal UserPersonalInfo `json:"-" bson:"personal"`
	Business UserBusinessInfo `json:"-" bson:"business"`
}

func NewUserWithChannel

func NewUserWithChannel(channel ChannelInfo) *User

func (*User) Count

func (this *User) Count(query map[string]interface{}) (int, error)

func (*User) FindAndModify

func (this *User) FindAndModify(query, change map[string]interface{}) error

func (*User) FindById

func (this *User) FindById(id interface{}) error

func (*User) FindOne

func (this *User) FindOne(query map[string]interface{}) error

func (*User) FindOrInsert

func (this *User) FindOrInsert(query map[string]interface{}, doc *User) (bool, error)

func (*User) Insert

func (this *User) Insert() error

func (*User) List

func (this *User) List(query map[string]interface{}, start, limit int, sort []string) ([]*User, error)

type UserBaseInfo

type UserBaseInfo struct {
	Name   string `json:"name" bson:"name"`
	Avatar *File  `json:"avatar,omitempty" bson:"avatar,omitempty"`
}

type UserBusinessInfo

type UserBusinessInfo struct {
	Importance TypeUserImportance
	Tips       []*UserTip
}

type UserLoginInfo

type UserLoginInfo struct {
	Password string `json:"-" bson:"password"`
}

type UserPersonalInfo

type UserPersonalInfo struct {
	Email              string            `json:"email" bson:"email"`
	EmailCertificated  bool              `json:"emailCertificated" bson:"emailCertificated"`
	Mobile             string            `json:"mobile" bson:"mobile"`
	MobileCertificated bool              `json:"mobileCertificated" bson:"mobileCertificated"`
	Extend             map[string]string `json:"extend" bson:"extend"`
}

type UserTip

type UserTip struct {
	Id      bson.ObjectId `json:"id" bson:"_id"`
	Content string        `json:"content" bson:"content"`
	Created int64         `json:"created" bson:"created"`
	Updated int64         `json:"updated" bson:"updated"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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