async def publish_product_search_first_page(ns={}): """ 普通客户查看 运营查看自己提交内容 运营查看所有用户内容 :param ns: :return: """ domain_name = ns.get('url_link').split("//")[1].split("/")[0] 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,) result = await sor.sqlExe(find_sql, {}) category_all = await sor.R('user_publish_product_category', {}) product_dic = {} for res in result: res['img'] = 'https://' + domain_name + '/idfile?path=' + res['img'] category_id = res['product_category'].split(',')[0] category_name_li = [item['product_category'] for item in category_all if item['id'] == category_id] category_name = category_name_li[0] if category_name_li else '其他' if product_dic.get(category_name): product_dic[category_name].append(res) else: product_dic[category_name] = [res] product_list = [] for key, value in product_dic.items(): product_list.append({'id': uuid(), 'name': key, 'product_list': value}) return { 'status': True, 'msg': 'Requirements retrieved successfully', 'data': product_list } except Exception as e: return { 'status': False, 'msg': 'Failed to retrieve requirements, %s' % str(e) } ret = await publish_product_search_first_page(params_kw) return ret