Exemple #1
0
    def put(self, *args, **kwargs):
        ret = {'status': False, 'summary': '', 'detail': {}}
        try:
            form = JdProductPriceForm()
            is_valid = form.valid(self)
            if is_valid:
                nid = form._value_dict.pop('nid')
                merchant_id = 14
                service = ProductService(ProductRepository())
                service.update_price(merchant_id,
                                     form._value_dict['product_id'], nid,
                                     form._value_dict)
            else:
                ret['detail'] = form._error_dict
                raise Exception('输入内容不合法')
            ret['status'] = True
        except Exception as e:
            ret['summary'] = str(e)

        self.write(json.dumps(ret))
Exemple #2
0
 def put(self, *args, **kwargs):
     ret = {"status": False, "summary": "", "detail": {}}
     try:
         form = JdProductPriceForm()
         is_valid = form.valid(self)
         if is_valid:
             nid = form._value_dict.pop("nid")
             merchant_id = 6
             service = ProductService(ProductRepository())
             service.update_price(merchant_id,
                                  form._value_dict["product_id"], nid,
                                  form._value_dict)
         else:
             ret["detail"] = form._error_dict
             raise Exception("输入内容不合法")
         ret['status'] = True
     except Exception as e:
         print(e)
         ret["summary"] = str(e)
     self.write(json.dumps(ret))