Пример #1
0
func ScanPrice(rows database.Scanner) (Price, error) {
	var p Price
	err := rows.Scan(
		&p.PartID,
		&p.Type,
		&p.Price,
	)
	return p, err
}
Пример #2
0
func ScanCartIntegration(rows database.Scanner) (CustomerPrice, error) {
	var c CustomerPrice
	var throwaway int
	err := rows.Scan(
		&throwaway,
		&c.PartID,
		&c.CustomerPartID,
		&c.CustID,
	)
	return c, err
}
Пример #3
0
//Utility
func Scan(rows database.Scanner) (CustomerPrice, error) {
	var c CustomerPrice
	var p, lp *float64
	var custPartId, id, custId, isSale *int
	var ss, se *time.Time
	var pt *string

	err := rows.Scan(
		&id,
		&custId,
		&c.PartID,
		&custPartId,
		&p,
		&isSale,
		&ss,
		&se,
		&pt,
		&lp,
	)
	if err != nil {
		return c, err
	}

	if id != nil {
		c.ID = *id
	}
	if custId != nil {
		c.CustID = *custId
	}
	if p != nil {
		c.Price = *p
	}
	if custPartId != nil {
		c.CustomerPartID = *custPartId
	}
	if isSale != nil {
		c.IsSale = *isSale
	}
	if ss != nil {
		c.SaleStart = ss
	}
	if se != nil {
		c.SaleEnd = se
	}
	if pt != nil {
		c.ListPrice.Type = *pt
	}
	if lp != nil {
		c.ListPrice.Price = *lp
	}
	return c, err
}
Пример #4
0
func PopulateLandingPageDataScan(s database.Scanner) (LandingPageData, error) {
	var d LandingPageData
	err := s.Scan(
		&d.Id,
		&d.LandingPageID,
		&d.DataKey,
		&d.DataValue,
	)
	if err != nil {
		return d, err
	}
	return d, nil
}
Пример #5
0
func PopulateLandingPageImageScan(s database.Scanner) (LandingPageImage, error) {
	var img LandingPageImage
	var urlstr *string
	err := s.Scan(
		&img.Id,
		&img.LandingPageID,
		&urlstr,
		&img.Sort,
	)
	if err != nil {
		return img, err
	}
	if urlstr != nil {
		img.Url, _ = url.Parse(*urlstr)
	}
	return img, nil
}
Пример #6
0
func (lp *LandingPage) PopulateLandingPageScan(s database.Scanner) error {
	var pageContent, linkClasses, conversionID, conversionLabel, urlstr *string

	err := s.Scan(
		&lp.Id,
		&lp.Name,
		&lp.StartDate,
		&lp.EndDate,
		&urlstr,
		&pageContent,
		&linkClasses,
		&conversionID,
		&conversionLabel,
		&lp.NewWindow,
		&lp.MenuPosition,
		&lp.WebsiteID,
	)
	if err != nil {
		return err
	}

	if pageContent != nil {
		lp.PageContent = *pageContent
	}
	if linkClasses != nil {
		lp.LinkClasses = *linkClasses
	}
	if conversionID != nil {
		lp.ConversionID = *conversionID
	}
	if conversionLabel != nil {
		lp.ConversionLabel = *conversionLabel
	}
	if urlstr != nil {
		lp.Url, _ = url.Parse(*urlstr)
	}
	lp.LandingPageDatas, _ = GetLandingPageDatas(lp.Id)
	lp.LandingPageImages, _ = GetLandingPageImages(lp.Id)

	return nil
}