update
This commit is contained in:
parent
f55e8e9f20
commit
0e5aea5a1c
@ -23,7 +23,8 @@ async def product_category_search(ns={}):
|
||||
orgid = user_list[0]['orgid']
|
||||
ns_dic = {'orgid': orgid, 'del_flg': '0'}
|
||||
try:
|
||||
result = await sor.R('user_publish_product_category', ns_dic)
|
||||
find_sql = """SELECT * FROM user_publish_product_category WHERE orgid = '%s' AND del_flg = '0' ORDER BY priority;""" % orgid
|
||||
result = await sor.sqlExe(find_sql, {})
|
||||
# res = await build_tree(parent_id=None, all_cats=result)
|
||||
return {
|
||||
'status': True,
|
||||
|
||||
@ -6,14 +6,35 @@ async def publish_product_search_first_page(ns={}):
|
||||
:param ns:
|
||||
:return:
|
||||
"""
|
||||
page_size = int(ns['page_size']) if ns.get('page_size') else 10
|
||||
offset = int(ns['offset'] - 1) if ns.get('offset') else 0
|
||||
to_page = ns.get('to_page') if ns.get('to_page') else 'first_page'
|
||||
domain_name = ns.get('url_link').split("//")[1].split("/")[0]
|
||||
company_type = ns.get('company_type')
|
||||
product_category = ns.get('product_category')
|
||||
if 'localhost' in domain_name:
|
||||
domain_name = 'dev.opencomputing.cn'
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('kboss') as sor:
|
||||
try:
|
||||
ns['del_flg'] = '0'
|
||||
find_sql = """SELECT * FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC;""" % (domain_name,)
|
||||
if to_page == 'first_page':
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC;""" % (domain_name,)
|
||||
find_sql = """SELECT upp.* FROM user_publish_product AS upp INNER JOIN user_publish_product_category AS uppc ON upp.product_category LIKE uppc.id WHERE upp.domain_name = '%s' AND upp.first_page = '1' AND upp.audit_status = 'approved' AND upp.del_flg = '0' ORDER BY uppc.priority ASC, upp.create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, page_size, offset)
|
||||
elif to_page == 'square' and product_category and company_type:
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND product_category LIKE """ % domain_name + """'%%""" + product_category + """%%'""" + """AND company_type LIKE """ + """'%%""" + company_type + """%%'""" + """ AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC;"""
|
||||
find_sql = """SELECT * FROM user_publish_product WHERE domain_name = '%s' AND product_category LIKE """ % domain_name + """'%%""" + product_category + """%%'""" + """AND company_type LIKE """ + """'%%""" + company_type + """%%'""" + """ AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (page_size, offset)
|
||||
elif to_page == 'square' and product_category:
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND product_category LIKE """ % domain_name + """'%%""" + product_category + """%%'""" + """ AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC;"""
|
||||
find_sql = """SELECT * FROM user_publish_product WHERE domain_name = '%s' AND product_category LIKE """ % domain_name + """'%%""" + product_category + """%%'""" + """ AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (page_size, offset)
|
||||
elif to_page == 'square':
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC;""" % (domain_name,)
|
||||
find_sql = """SELECT * FROM user_publish_product WHERE domain_name = '%s' AND audit_status = 'approved' AND del_flg = '0' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, page_size, offset)
|
||||
else:
|
||||
count_sql = ''
|
||||
find_sql = ''
|
||||
|
||||
total_count = (await sor.sqlExe(count_sql, {}))[0]['total_count']
|
||||
result = await sor.sqlExe(find_sql, {})
|
||||
category_all = await sor.R('user_publish_product_category', {})
|
||||
product_dic = {}
|
||||
@ -28,7 +49,7 @@ async def publish_product_search_first_page(ns={}):
|
||||
product_dic[category_name] = [res]
|
||||
product_list = []
|
||||
for key, value in product_dic.items():
|
||||
product_list.append({'id': uuid(), 'name': key, 'product_list': value})
|
||||
product_list.append({'id': uuid(), 'name': key, 'total_count': total_count, 'page_size': page_size, 'current_page': offset + 1, 'product_list': value})
|
||||
return {
|
||||
'status': True,
|
||||
'msg': 'Requirements retrieved successfully',
|
||||
@ -39,6 +60,5 @@ async def publish_product_search_first_page(ns={}):
|
||||
'status': False,
|
||||
'msg': 'Failed to retrieve requirements, %s' % str(e)
|
||||
}
|
||||
|
||||
ret = await publish_product_search_first_page(params_kw)
|
||||
return ret
|
||||
Loading…
x
Reference in New Issue
Block a user