Пример #1
0
func PopulateMenuItem(row mysql.Row, res mysql.Result, ch chan MenuItem) {
	var item MenuItem

	mcid := res.Map("menuContentID")
	menuID := res.Map("menuID")
	contentID := res.Map("contentID")
	menuSort := res.Map("menuSort")
	menuTitle := res.Map("menuTitle")
	menuLink := res.Map("menuLink")
	parentID := res.Map("parentID")
	linkTarget := res.Map("linkTarget")

	id := row.Int(mcid)
	if id > 0 {
		cid := row.Int(contentID)
		cch := make(chan Content)
		go PopulateContent(row, res, cch)

		item = MenuItem{
			ID:         id,
			MenuID:     row.Int(menuID),
			ContentID:  cid,
			Sort:       row.Int(menuSort),
			Title:      row.Str(menuTitle),
			Link:       row.Str(menuLink),
			ParentID:   row.Int(parentID),
			LinkTarget: row.Bool(linkTarget),
			Content:    <-cch,
		}
	}

	ch <- item
}
Пример #2
0
func (c Customer) PopulateCustomer(row mysql.Row, res mysql.Result, ch chan Customer) {
	customer := Customer{
		ID:            row.Int(res.Map("cust_id")),
		Name:          row.Str(res.Map("name")),
		Email:         row.Str(res.Map("email")),
		Address:       row.Str(res.Map("address")),
		Address2:      row.Str(res.Map("address2")),
		City:          row.Str(res.Map("city")),
		StateID:       row.Int(res.Map("stateID")),
		PostalCode:    row.Str(res.Map("postal_code")),
		Phone:         row.Str(res.Map("phone")),
		Fax:           row.Str(res.Map("fax")),
		ContactPerson: row.Str(res.Map("contact_person")),
		DealerTypeID:  row.Int(res.Map("dealer_type")),
		Latitude:      row.Str(res.Map("latitude")),
		Longitude:     row.Str(res.Map("longitude")),
		Website:       row.Str(res.Map("website")),
		CustomerID:    row.Int(res.Map("customerID")),
		IsDummy:       row.Bool(res.Map("isDummy")),
		ParentID:      row.Int(res.Map("parentID")),
		SearchURL:     row.Str(res.Map("searchURL")),
		ELocalURL:     row.Str(res.Map("eLocalURL")),
		Logo:          row.Str(res.Map("logo")),
		MapicsCodeID:  row.Int(res.Map("mCodeID")),
		SalesRepID:    row.Int(res.Map("salesRepID")),
		APIKey:        row.Str(res.Map("APIKey")),
		Tier:          row.Int(res.Map("tier")),
		ShowWebsite:   row.Bool(res.Map("showWebsite")),
		LocationCount: row.Int(res.Map("locationCount")),
		UserCount:     row.Int(res.Map("userCount")),
		PropertyCount: row.Int(res.Map("propertyCount")),
	}

	ch <- customer
}
Пример #3
0
func (c BlogCategory) PopulateCategory(row mysql.Row, res mysql.Result, ch chan BlogCategory) {
	category := BlogCategory{
		ID:     row.Int(res.Map("blogCategoryID")),
		Name:   row.Str(res.Map("name")),
		Slug:   row.Str(res.Map("slug")),
		Active: row.Bool(res.Map("active")),
	}
	ch <- category
}
Пример #4
0
func (d DealerType) PopulateType(row mysql.Row, res mysql.Result, ch chan DealerType) {
	dealertype := DealerType{
		ID:     row.Int(res.Map("dealer_type")),
		Name:   row.Str(res.Map("type")),
		Online: row.Bool(res.Map("online")),
		Show:   row.Bool(res.Map("show")),
		Label:  row.Str(res.Map("label")),
	}
	ch <- dealertype
}
Пример #5
0
func (n NewsItem) PopulateNewsItem(row mysql.Row, res mysql.Result, ch chan NewsItem) {
	item := NewsItem{
		ID:           row.Int(res.Map("newsItemID")),
		Title:        row.Str(res.Map("title")),
		Lead:         row.Str(res.Map("lead")),
		Content:      row.Str(res.Map("content")),
		PublishStart: row.Time(res.Map("publishStart"), UTC),
		PublishEnd:   row.Time(res.Map("publishEnd"), UTC),
		Active:       row.Bool(res.Map("active")),
		Slug:         row.Str(res.Map("slug")),
	}
	ch <- item
}
Пример #6
0
func (c Comment) PopulateComment(row mysql.Row, res mysql.Result, ch chan Comment) {
	comment := Comment{
		ID:       row.Int(res.Map("commentID")),
		PostID:   row.Int(res.Map("blogPostID")),
		Name:     row.Str(res.Map("name")),
		Email:    row.Str(res.Map("email")),
		Comment:  row.Str(res.Map("comment_text")),
		Created:  row.Time(res.Map("createdDate"), UTC),
		Approved: row.Bool(res.Map("approved")),
		Active:   row.Bool(res.Map("active")),
	}
	ch <- comment
}
Пример #7
0
func (t Testimonial) PopulateTestimonial(row mysql.Row, res mysql.Result, ch chan Testimonial) {
	testimonial := Testimonial{
		ID:        row.Int(res.Map("testimonialID")),
		Rating:    row.Float(res.Map("rating")),
		Title:     row.Str(res.Map("title")),
		Content:   row.Str(res.Map("testimonial")),
		DateAdded: row.Time(res.Map("dateAdded"), UTC),
		Approved:  row.Bool(res.Map("approved")),
		Active:    row.Bool(res.Map("active")),
		FirstName: row.Str(res.Map("first_name")),
		LastName:  row.Str(res.Map("last_name")),
		Location:  row.Str(res.Map("location")),
	}
	ch <- testimonial
}
Пример #8
0
func PopulateRevision(row mysql.Row, res mysql.Result, ch chan ContentRevision) {
	var revision ContentRevision

	id := res.Map("revisionID")
	contentID := res.Map("contentID")
	contentText := res.Map("content_text")
	createdOn := res.Map("createdOn")
	active := res.Map("active")

	revision = ContentRevision{
		ID:          row.Int(id),
		ContentID:   row.Int(contentID),
		ContentText: row.Str(contentText),
		CreatedOn:   row.Time(createdOn, UTC),
		Active:      row.Bool(active),
	}

	ch <- revision
}
Пример #9
0
func (c CustomerLocation) PopulateLocation(row mysql.Row, res mysql.Result, ch chan CustomerLocation) {
	location := CustomerLocation{
		ID:              row.Int(res.Map("locationID")),
		CustomerID:      row.Int(res.Map("cust_id")),
		Name:            row.Str(res.Map("name")),
		Address:         row.Str(res.Map("address")),
		City:            row.Str(res.Map("city")),
		StateID:         row.Int(res.Map("stateID")),
		PostalCode:      row.Str(res.Map("postalCode")),
		Email:           row.Str(res.Map("email")),
		Phone:           row.Str(res.Map("phone")),
		Fax:             row.Str(res.Map("fax")),
		Latitude:        row.Float(res.Map("latitude")),
		Longitude:       row.Float(res.Map("longitude")),
		ContactPerson:   row.Str(res.Map("contact_person")),
		IsPrimary:       row.Bool(res.Map("isprimary")),
		ShippingDefault: row.Bool(res.Map("ShippingDefault")),
	}
	ch <- location
}
Пример #10
0
func (l LandingPage) populateLandingPage(row mysql.Row, res mysql.Result, ch chan LandingPage) {
	page := LandingPage{
		ID:              row.Int(res.Map("id")),
		Name:            row.Str(res.Map("name")),
		Start:           row.Time(res.Map("startDate"), UTC),
		End:             row.Time(res.Map("endDate"), UTC),
		URL:             row.Str(res.Map("url")),
		Content:         row.Str(res.Map("pageContent")),
		LinkClasses:     row.Str(res.Map("linkClasses")),
		ConversionID:    row.Str(res.Map("conversionID")),
		ConversionLabel: row.Str(res.Map("conversionLabel")),
		NewWindow:       row.Bool(res.Map("newWindow")),
		MenuPosition:    row.Str(res.Map("menuPosition")),
	}
	dch := make(chan []LandingPageData)
	ich := make(chan LandingPageImages)
	go page.getImages(ich)
	go page.getData(dch)
	page.Images = <-ich
	page.Data = <-dch

	ch <- page
}
Пример #11
0
func (p Post) PopulatePost(row mysql.Row, res mysql.Result, ch chan Post) {
	post := Post{
		ID:           row.Int(res.Map("blogPostID")),
		Title:        row.Str(res.Map("post_title")),
		Slug:         row.Str(res.Map("slug")),
		Content:      row.Str(res.Map("post_text")),
		Published:    row.Time(res.Map("publishedDate"), UTC),
		Created:      row.Time(res.Map("createdDate"), UTC),
		LastModified: row.Time(res.Map("lastModified"), UTC),
		UserID:       row.Int(res.Map("userID")),
		MetaTitle:    row.Str(res.Map("meta_title")),
		MetaDesc:     row.Str(res.Map("meta_description")),
		Keywords:     row.Str(res.Map("keywords")),
		Active:       row.Bool(res.Map("active")),
	}
	catchan := make(chan BlogCategories)
	comchan := make(chan Comments)
	authchan := make(chan User)
	go func(ch chan User) {
		author, _ := GetUserByID(post.UserID)
		ch <- author
	}(authchan)
	go func(ch chan Comments) {
		comments, _ := post.GetComments()
		ch <- comments
	}(comchan)
	go func(ch chan BlogCategories) {
		categories, _ := post.GetCategories()
		ch <- categories
	}(catchan)

	post.Author = <-authchan
	post.Categories = <-catchan
	post.Comments = <-comchan
	ch <- post
}
Пример #12
0
func (c CustomerUser) PopulateUser(row mysql.Row, res mysql.Result, ch chan CustomerUser) {
	user := CustomerUser{
		ID:          row.Str(res.Map("id")),
		CustID:      row.Int(res.Map("cust_ID")),
		CustomerID:  row.Int(res.Map("customerID")),
		Name:        row.Str(res.Map("name")),
		Email:       row.Str(res.Map("email")),
		DateAdded:   row.Time(res.Map("date_added"), UTC),
		Active:      row.Bool(res.Map("active")),
		LocationID:  row.Int(res.Map("locationID")),
		IsSudo:      row.Bool(res.Map("isSudo")),
		NotCustomer: row.Bool(res.Map("NotCustomer")),
	}
	ch <- user
}
Пример #13
0
func PopulateMenu(row mysql.Row, res mysql.Result, ch chan Menu) {
	id := res.Map("menuID")
	name := res.Map("menu_name")
	isPrimary := res.Map("isPrimary")
	active := res.Map("active")
	displayName := res.Map("display_name")
	reqAuth := res.Map("requireAuthentication")
	showOnSitemap := res.Map("showOnSitemap")
	sort := res.Map("sort")
	var menu Menu

	menu = Menu{
		ID:            row.Int(id),
		Name:          row.Str(name),
		Primary:       row.Bool(isPrimary),
		Active:        row.Bool(active),
		DisplayName:   row.Str(displayName),
		RequireAuth:   row.Bool(reqAuth),
		ShowOnSitemap: row.Bool(showOnSitemap),
		Sort:          row.Int(sort),
	}

	ch <- menu
}
Пример #14
0
func PopulateContent(row mysql.Row, res mysql.Result, ch chan Content) {
	cid := res.Map("contentID")
	contentType := res.Map("content_type")
	pageTitle := res.Map("page_title")
	createdDate := res.Map("createdDate")
	lastModified := res.Map("lastModified")
	metaTitle := res.Map("meta_title")
	metaDesc := res.Map("meta_description")
	keywords := res.Map("keywords")
	isPrimary := res.Map("isPrimary")
	published := res.Map("published")
	active := res.Map("active")
	slug := res.Map("slug")
	requireAuth := res.Map("requireAuthentication")
	canonical := res.Map("canonical")
	var content Content

	id := row.Int(cid)
	revCh := make(chan ContentRevisions)
	go GetContentRevisions(id, revCh)
	revisions := <-revCh
	content = Content{
		ID:              id,
		ContentType:     row.Str(contentType),
		PageTitle:       row.Str(pageTitle),
		CreatedDate:     row.Time(createdDate, UTC),
		LastModified:    row.Time(lastModified, UTC),
		MetaTitle:       row.Str(metaTitle),
		MetaDescription: row.Str(metaDesc),
		Keywords:        row.Str(keywords),
		Primary:         row.Bool(isPrimary),
		Published:       row.Bool(published),
		Active:          row.Bool(active),
		Slug:            row.Str(slug),
		RequireAuth:     row.Bool(requireAuth),
		Canonical:       row.Str(canonical),
		Revisions:       revisions,
		ActiveRevision:  revisions.GetActiveRevision(),
	}
	ch <- content
}