1234567891011121314151617181920212223242526272829303132333435 |
- package backend
- import (
- "context"
- "encoding/json"
- "kpt-pasture/model"
- "gitee.com/xuyiping_admin/pkg/xerr"
- )
- type MilkBrand interface {
- SaveData(ctx context.Context) 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, body: body}
- case model.AFI:
- milkBrand = &AFI{store: s, body: body}
- case model.GEA:
- milkBrand = &GEAMILK{store: s, body: body}
- default:
- return xerr.Customf("不支持的品牌: %s", body.Brand)
- }
-
- return milkBrand.SaveData(ctx)
- }
|