Exemplo n.º 1
0
 def un_tag_product(self, itemid):
     es_rs = es_dao_local().es_get(
         itemid, {
             "_source":
             ",".join([
                 'isdir', 'fs_id', 'size', 'account', 'tags', 'filename',
                 'parent', 'sourceid'
             ])
         })
     if es_rs and "_source" in es_rs:
         source = es_rs["_source"]
         tags = source["tags"]
         if PRODUCT_TAG in tags:
             tags.remove(PRODUCT_TAG)
             es_dao_local().update_field(itemid, 'tags', tags)
         ProductDao.update_product(itemid, {'pin': 1})
Exemplo n.º 2
0
def product_dao_test():
    global pdt
    pdt = ProductDao()
    [print(row) for row in pdt.select_product()]
    [
        print(row) for row in pdt.select_product(
            sql="select * from product where code like %s", code='A%')
    ]
    sdt = SaleDao()
    [print(row) for row in sdt.select_item()]
    # sdt.insert_item(code='A001', price=5000, saleCnt=10, marginRate=10)
    [print(row) for row in sdt.select_item(no=1)]
    select_product()
    pdt.insert_product("Insert into product values(%s, %s)", 'C001', '라떼')
    select_product()
    pdt.update_product("update product set name = %s where code = %s", '라떼수정',
                       'C001')
    select_product()
    pdt.delete_product("delete from product where code = %s", 'C001')
    select_product()
Exemplo n.º 3
0
 def tag_product(self, ref_id, itemid, layer, p_price) -> Product:
     es_rs = es_dao_local().es_get(
         itemid, {
             "_source":
             ",".join([
                 'isdir', 'fs_id', 'size', 'account', 'tags', 'filename',
                 'parent', 'sourceid'
             ])
         })
     logger.info("es_rs:{},layer:{},price:{}".format(es_rs, layer, p_price))
     if es_rs and "_source" in es_rs:
         source = es_rs["_source"]
         isdir = source["isdir"]
         size = source["size"]
         # format_size = scale_size(size)
         tags = source["tags"]
         if not tags:
             tags = []
         if PRODUCT_TAG not in tags:
             tags.append(PRODUCT_TAG)
             es_dao_local().update_field(itemid, 'tags', tags)
         pro: Product = ProductDao.product_by_pro_no(itemid)
         if not pro:
             pro = ProductDao.new_product(
                 itemid, ref_id, {
                     'isdir': isdir,
                     'name': source['filename'],
                     'fs_id': source['fs_id'],
                     'size': size,
                     'price': int(p_price * 100)
                 })
         else:
             ProductDao.update_product(itemid, {
                 'pin': 0,
                 'price': int(p_price * 100)
             })
         return pro
 def get_item_form_le_updatepdt(self, le_code, le_name):
     pdt = ProductDao()
     code = le_code
     name = le_name
     pdt.update_product(name, code)
     return self.create_item(code, name)