コード例 #1
0
ファイル: redis_material.go プロジェクト: ifzz/seller_adptor
func (this *ReqRedisModule) fill_material(ad *context.AdInfo, material *jesgoo_protocol.Material) (err error) {

	if ad.Adid != int64(*material.Id) {
		err = errors.New("id is not equal")
		return
	}

	/*	switch *material.Type {
		case jesgoo_protocol.Material_TEXT:
			if ad.AdType != context.TEXT {
				str := fmt.Sprintf("adid[%d] is not TEXT in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		case jesgoo_protocol.Material_IMAGE:
			if ad.AdType != context.IMAGE {
				str := fmt.Sprintf("adid[%d] is not IMAGE in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		case jesgoo_protocol.Material_ICON_TEXT:
			if ad.AdType != context.TEXT_ICON {
				str := fmt.Sprintf("adid[%d] is not ICON_TEXT in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		default:
			str := fmt.Sprintf("adid[%d] is UNKNOWN is bs", ad.Adid)
			err = errors.New(str)
			return
		}
	*/
	if material.Title != nil {
		ad.Title = *material.Title
	}
	if material.Description != nil {
		ad.Description1 = *material.Description
	}
	if material.Image != nil {
		ad.ImageUrl = *material.Image.Url
	}
	if material.TargetUrl != nil {
		ad.ClickUrl = *material.TargetUrl
	}
	if material.App != nil {
		ad.Appname = *material.App.Name
		ad.Package = *material.App.PackageName
		ad.LogoUrl = *material.App.Logo.Url
		if material.App.PackageSize != nil {
			ad.PackageSize = (*material.App.PackageSize) >> 20
		}
	}
	if material.LongDescription != nil {
		ad.Description2 = *material.LongDescription
	}
	ad.MaterialReady = true
	return
}