|
|
|
package sku
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.oa00.com/supply-chain/service/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type banner struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type BannerItem struct {
|
|
|
|
Id uint `json:"id"`
|
|
|
|
Img string `json:"img"`
|
|
|
|
SkuId uint `json:"skuId"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// All @Title 全部轮播图
|
|
|
|
func (b *banner) All(ctx context.Context) (reply []BannerItem, err error) {
|
|
|
|
xClient, err := client.GetClient(b)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
args := 0
|
|
|
|
err = xClient.Call(ctx, "All", args, &reply)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgsSkuBannerEdit struct {
|
|
|
|
Id uint
|
|
|
|
SkuId uint
|
|
|
|
Img string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edit @Title 编辑轮播图
|
|
|
|
func (b *banner) Edit(ctx context.Context, args ArgsSkuBannerEdit) (err error) {
|
|
|
|
xClient, err := client.GetClient(b)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
reply := 0
|
|
|
|
return xClient.Call(ctx, "Edit", args, &reply)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Del @Title 删除轮播图
|
|
|
|
func (b *banner) Del(ctx context.Context, id uint) (err error) {
|
|
|
|
xClient, err := client.GetClient(b)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
reply := 0
|
|
|
|
return xClient.Call(ctx, "Del", id, &reply)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DelBySkuId @Title 根据skuId删除
|
|
|
|
func (b *banner) DelBySkuId(ctx context.Context, skuId uint) (err error) {
|
|
|
|
xClient, err := client.GetClient(b)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
reply := 0
|
|
|
|
return xClient.Call(ctx, "DelBySkuId", skuId, &reply)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgsSkuBannerAdd struct {
|
|
|
|
SkuId uint
|
|
|
|
Img string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add @Title 添加轮播图
|
|
|
|
func (b *banner) Add(ctx context.Context, args ArgsSkuBannerAdd) error {
|
|
|
|
xClient, err := client.GetClient(b)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
reply := 0
|
|
|
|
return xClient.Call(ctx, "Add", args, &reply)
|
|
|
|
}
|