1234567891011121314151617181920212223242526272829303132333435 |
- package backend
- import (
- "context"
- "encoding/json"
- "kpt-pasture/model"
- "gitee.com/xuyiping_admin/pkg/xerr"
- )
- // MilkBrand 奶厅品牌接口
- type MilkBrand interface {
- SaveData(ctx context.Context, body *model.MilkHallBody) error
- }
- func (s *StoreEntry) MilkHallOriginal(ctx context.Context, req []byte) error {
- body := &model.MilkHallBody{}
- if err := json.Unmarshal(req, body); err != nil {
- return xerr.WithStack(err)
- }
- var milkBrand MilkBrand
- switch body.Brand {
- case model.AFIMilk:
- milkBrand = &AFIMILK{store: s}
- case model.AFI:
- milkBrand = &AFI{store: s}
- case model.GEA:
- milkBrand = &GEAMILK{store: s}
- default:
- return xerr.Customf("不支持的品牌: %s", body.Brand)
- }
- // 调用品牌的 SaveData 方法
- return milkBrand.SaveData(ctx, body)
- }
|