Exemplo n.º 1
0
// 保存图片广告
func (this *adService) SaveImageAd(adUserId int, v *ad.Image) (int, error) {
	pa := this.getUserAd(adUserId)
	var adv ad.IAd = pa.GetById(v.AdId)
	if adv.Type() == ad.TypeImage {
		g := adv.(ad.IImageAd)
		g.SetData(v)
		return adv.Save()
	}
	return -1, nil
}
Exemplo n.º 2
0
// 删除广告图片
func (this *adService) DelAdImage(adUserId, advertisementId, imgId int) error {
	pa := this.getUserAd(adUserId)
	var adv ad.IAd = pa.GetById(advertisementId)
	if adv != nil {
		if adv.Type() == ad.TypeGallery {
			gad := adv.(ad.IGalleryAd)
			return gad.DelImage(imgId)
		}
	}
	return nil
}
Exemplo n.º 3
0
// 保存广告,更新时不允许修改类型
func (this *adService) SaveAd(adUserId int, v *ad.Ad) (int, error) {
	pa := this.getUserAd(adUserId)
	var adv ad.IAd
	if v.Id > 0 {
		adv = pa.GetById(v.Id)
		err := adv.SetValue(v)
		if err != nil {
			return -1, err
		}
	} else {
		adv = pa.CreateAd(v)
	}
	return adv.Save()
}
Exemplo n.º 4
0
// 保存广告图片
func (this *adService) SaveImage(adUserId int, advertisementId int, v *ad.Image) (int, error) {
	pa := this.getUserAd(adUserId)
	var adv ad.IAd = pa.GetById(advertisementId)
	if adv != nil {
		switch adv.Type() {
		case ad.TypeGallery:
			gad := adv.(ad.IGalleryAd)
			return gad.SaveImage(v)
		case ad.TypeImage:
			gad := adv.(ad.IImageAd)
			gad.SetData(v)
			return adv.Save()
		}
	}
	return -1, ad.ErrNoSuchAd
}