def get(self,*args,**kwargs): #获取一级分类 #循环一级分类,获取二级分类 #循环二级分类,获取三级分类 c=CategoryService(CategoryRepository()) category_list=c.fetch_all_category() p=ProductService(ProductRepository()) product_dict=p.fetch_index_product()
def get(self, *args, **kwargs): # 数据库中获取数据,显示在页面 merchant_id = 14 product_id = self.get_argument('productid', None) service = ProductService(ProductRepository()) series = service.get_product_detail(merchant_id, product_id) self.render('Product/JdProductDetail.html', product_id=product_id)
def get(self, *args, **kwargs): product_id = kwargs.get('product_id', None) price_id = kwargs.get('price_id', None) if not product_id or not price_id: self.redirect('/Index.html') return # 根据商品ID获取商品信息,商户信息,价格列表,图片 p = ProductService(ProductRepository()) product_dict = p.fetch_product_detail(product_id, price_id) self.render('Home/Detail.html', product_dict=product_dict)
def get(self, *args, **kwargs): # 获取一级分类 # 循环一级分类,获取二级分类 # 循环二级分类,获取三级分类 c = CategoryService(CategoryRepository()) category_list = c.get_all_category() p = ProductService(ProductRepository()) product_dict = p.fetch_index_product() self.render('Home/Index.html', category_list=category_list, product_dict=product_dict)
def get(self, *args, **kwargs): summary = 'success' product_id = self.get_argument('productid', None) try: if not product_id: raise Exception('请输入商品ID') ip = self.request.remote_ip service = ProductService(ProductRepository()) service.create_puv(product_id, ip) except Exception as e: summary = str(e) self.write(summary)
def get(self, *args, **kwargs): ret = {"status": False, "summary": "", "data": []} try: merchant_id = 6 product_id = self.get_argument("product_id", None) if not product_id: raise Exception("请输入商品ID") service = ProductService(ProductRepository()) series = service.get_upv(merchant_id, product_id) ret["data"] = series ret["status"] = True except Exception as e: ret["summary"] = str(e) self.write(json.dumps(ret))
def get(self, *args, **kwargs): ret = {'status': False, 'summary': '', 'data': []} try: merchant_id = 14 product_id = self.get_argument('product_id', None) if not product_id: raise Exception('请输入产品ID') service = ProductService(ProductRepository()) series = service.get_upv(merchant_id, product_id) ret['data'] = series ret['status'] = True except Exception as e: ret['summary'] = str(e) self.write(json.dumps(ret))
def get(self, *args, **kwargs): ret = {"status": False, "summary": "", "total": 0, "row": []} try: product_id = self.get_argument("product_id", None) if not product_id: raise Exception("商品id不能为空") merchant_id = 6 service = ProductService(ProductRepository()) total, result = service.get_price_by_product_id( merchant_id=merchant_id, product_id=product_id) ret["total"] = total ret['rows'] = result ret["status"] = True except Exception as e: ret["summary"] = str(e) self.write(json.dumps(ret, cls=JsonCustomEncoder))
def post(self, *args, **kwargs): ret = {"status": False, "summary": "", "detail": ""} form = JdProductForm() try: is_valid = form.valid(self) if is_valid: merchant_id = 6 print("data", form._value_dict) service = ProductService(ProductRepository()) service.create_product(merchant_id, form._value_dict) ret["status"] = True else: ret["detail"] = form._error_dict except Exception as e: ret["summary"] = str(e) self.write(json.dumps(ret))
def post(self, *args, **kwargs): ret = {'status': False, 'summary': '', 'detail': ""} form = JdProductForm() try: is_valid = form.valid(self) if is_valid: # print(is_valid, form._error_dict, form._value_dict) merchant_id = 14 service = ProductService(ProductRepository()) service.create_product(merchant_id, form._value_dict) ret['status'] = True else: ret['detail'] = form._error_dict except Exception as e: ret['summary'] = str(e) self.write(json.dumps(ret))
def delete(self, *args, **kwargs): product_id = self.get_argument("nid") print(product_id) ret = {"summary": "", "status": False} if product_id: try: service = ProductService(ProductRepository()) db_result = service.delete_product(product_id) if db_result: ret["status"] = True else: raise Exception("删除失败") except Exception as e: print(e) ret["summary"] = str(e) else: ret["summary"] = "请选择要删除的行" self.write(json.dumps(ret))
def delete(self, *args, **kwargs): ret = { "summary": "", "status": False, } nid = self.get_argument("nid", None) if nid: try: service = ProductService(ProductRepository()) result = service.delete_price(nid) if not result: raise Exception("删除失败") ret["status"] = True except Exception as e: ret["summary"] = str(e) else: ret['summary'] = "请选择要陕删除的行" self.write(json.dumps(ret))
def get(self, *args, **kwargs): ret = {'status': False, 'summary': '', 'total': 0, 'rows': []} try: product_id = self.get_argument('productid', None) if not product_id: raise Exception('商品ID不能为空') merchant_id = 14 service = ProductService(ProductRepository()) total, result = service.get_price_by_product_id( merchant_id=merchant_id, product_id=product_id) ret['total'] = total ret['rows'] = result ret['status'] = True except Exception as e: ret['summary'] = str(e) self.write(json.dumps(ret, cls=JsonCustomEncoder))
def get(self, *args, **kwargs): ret = {"status": False, "summary": "", "data": {}} try: product_id = self.get_argument('product_id', None) if not product_id: raise Exception("请输入产品Id") else: merchant_id = 6 service = ProductService(ProductRepository()) data = service.get_product_by_id(merchant_id=merchant_id, product_id=product_id) if not data: raise Exception("未获取到商品信息") ret["status"] = True ret["data"] = data except Exception as e: ret["summary"] = str(e) self.render("Product/JdProductPriceManager.html", **ret)
def get(self, *args, **kwargs): ret = {'status': False, 'summary': '', 'data': {}} try: product_id = self.get_argument('productid', None) if not product_id: raise Exception('请输入商品ID') merchant_id = 14 service = ProductService(ProductRepository()) result = service.get_product_by_id(merchant_id=merchant_id, product_id=product_id) if not result: raise Exception('未获取商品信息') ret['status'] = True ret['data'] = result except Exception as e: ret['summary'] = str(e) self.render('Product/JdProductPriceManager.html', **ret)
def get(self, *args, **kwargs): # 根据参数,获取产品信息(type:自营(商户ID),type:所有商品) # 后台管理用户登陆成功后,Session中保存自营ID # 自营ID=1 ret = {"status": False, "message": "", "total": 0, "rows": []} try: merchant_id = 6 page = int(self.get_argument("page", 1)) rows = int(self.get_argument("rows", 10)) start = (page - 1) * 10 service = ProductService(ProductRepository()) total, data = service.get_page_by_merchant_id( merchant_id, start, rows) ret["status"] = True ret["total"] = total ret["rows"] = data except Exception as e: ret["message"] = str(e) self.write(json.dumps(ret))
def get(self, *args, **kwargs): error_summary = "" product_id = self.get_argument("product_id", None) if not product_id: crumbs = "添加产品" method = "post" else: crumbs = "编辑产品" method = "put" #根据产品id获取产品信息 merchant_id = 6 service = ProductService(ProductRepository()) data = service.get_product_by_id(merchant_id, product_id) print(data) self.render("Product/JdProductEdit.html", crumbs=crumbs, method=method, data=data)
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))
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))
def get(self, *args, **kwargs): # 根据参数,获取产品信息(type:自营(商户ID),type:所有商品) # 后台管理用户登陆成功后,Session中保存自营ID # 自营ID=1 ret = {'status': False, 'message': '', 'total': 0, 'rows': []} try: # 手动获取京东自营ID为14 merchant_id = 14 page = int(self.get_argument('page', 1)) rows = int(self.get_argument('rows', 10)) start = (page - 1) * rows service = ProductService(ProductRepository()) total, result = service.get_page_by_merchant_id( merchant_id, start, rows) ret['status'] = True ret['total'] = total ret['rows'] = result except Exception as e: ret['message'] = str(e) self.write(json.dumps(ret))
def get(self, *args, **kwargs): merchant_id = 6 product_id = self.get_argument("product_id", None) service = ProductService(ProductRepository()) series = service.get_product_detail(merchant_id, product_id) self.render("Product/JdProductDetail.html", series=series)