// 保存产品 func (this *saleService) SaveItem(partnerId int, v *sale.ValueItem) (int, error) { sl := this._rep.GetSale(partnerId) var pro sale.IItem if v.Id > 0 { pro = sl.GetItem(v.Id) if pro == nil { return 0, errors.New("产品不存在") } // 修改货品时,不会修改详情 v.Description = pro.GetValue().Description if err := pro.SetValue(v); err != nil { return 0, err } } else { pro = sl.CreateItem(v) } return pro.Save() }
func (this *goodsC) Edit(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.Response var e *sale.ValueItem id, _ := strconv.Atoi(r.URL.Query().Get("item_id")) e = dps.SaleService.GetValueItem(partnerId, id) if e == nil { w.Write([]byte("商品不存在")) return } e.Description = "" js, _ := json.Marshal(e) shopChks := cache.GetShopCheckboxs(partnerId, e.ApplySubs) cateOpts := cache.GetDropOptionsOfCategory(partnerId) ctx.App.Template().Execute(w, gof.TemplateDataMap{ "entity": template.JS(js), "shop_chk": template.HTML(shopChks), "cate_opts": template.HTML(cateOpts), }, "views/partner/goods/update_goods.html") }