This commit is contained in:
ping 2025-08-04 13:49:41 +08:00
parent 0f76206df4
commit ac6b65d800
3 changed files with 66 additions and 24 deletions

View File

@ -44,6 +44,7 @@ async def publish_product_add(ns={}):
company_type = ns.get('company_type')
ns_dic = {
"id": uuid(),
"publish_type": ns.get("publish_type"),
"orgid": orgid,
"img": ns.get('img'),
"domain_name": domain_name,
@ -62,6 +63,8 @@ async def publish_product_add(ns={}):
"data_disk": ns.get("data_disk"),
"net_card": ns.get("net_card"),
"price": ns.get("price"),
"unit": ns.get("unit"),
"short_term": ns.get("short_term"),
"priority": ns.get("priority") if ns.get("priority") else 1,
"status": ns.get("status") if ns.get("status") else '0',
"title": ns.get("title"),
@ -90,5 +93,6 @@ async def publish_product_add(ns={}):
'msg': 'Failed to publish product, %s' % str(e)
}
ret = await publish_product_add(params_kw)
return ret

View File

@ -6,6 +6,7 @@ async def publish_product_search_first_page(ns={}):
:param ns:
:return:
"""
publish_type = ns.get('publish_type')
page_size = int(ns['page_size']) if ns.get('page_size') else 8
current_page_param = int(ns['current_page']) if ns.get('current_page') else 1
current_page = (current_page_param - 1) * page_size
@ -20,14 +21,14 @@ async def publish_product_search_first_page(ns={}):
try:
ns['del_flg'] = '0'
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, current_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' AND publish_type = '%s' ORDER BY create_at DESC;""" % (domain_name, publish_type)
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' AND upp.publish_type = '%s' ORDER BY uppc.priority ASC, upp.create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, publish_type, page_size, current_page)
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, current_page)
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' AND publish_type = '%s' ORDER BY create_at DESC;""" % publish_type
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' AND publish_type = '%s' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (publish_type, page_size, current_page)
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, current_page)
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND audit_status = 'approved' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC;""" % (domain_name, publish_type)
find_sql = """SELECT * FROM user_publish_product WHERE domain_name = '%s' AND audit_status = 'approved' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, publish_type, page_size, current_page)
else:
count_sql = ''
find_sql = ''

View File

@ -1,24 +1,61 @@
async def requirement_add(ns={}):
if ns.get('userid'):
userid = ns.get('userid')
else:
userid = await get_user()
db = DBPools()
async with db.sqlorContext('kboss') as sor:
# 区分运营和普通客户
user_list = await sor.R('users', {'id': userid})
if not user_list:
return {
'status': False,
'msg': '没有找到匹配的用户'
}
orgid = user_list[0]['orgid']
domain_name = ns.get('url_link').split("//")[1].split("/")[0]
if 'localhost' in domain_name:
domain_name = 'dev.opencomputing.cn'
product_category = ns.get('product_category')
company_type = ns.get('company_type')
ns_dic = {
'id': uuid(),
'orgid': ns.get('orgid'),
'requirement_name': ns.get('requirement_name'),
'product_category': json.dumps(product_category) if isinstance(product_category, list) else product_category,
'company_name': ns.get('company_name'),
'company_type': json.dumps(company_type) if isinstance(company_type, list) else company_type,
'contact_person': ns.get('contact_person'),
'job_title': ns.get('job_title'),
'phone_number': ns.get('phone_number'),
'email': ns.get('email'),
'requirement_summary': ns.get('requirement_summary'),
'related_parameters': ns.get('related_parameters'),
'application_scenario': ns.get('application_scenario'),
'audit_status': ns.get('audit_status', 'pending')
"id": uuid(),
"orgid": orgid,
"domain_name": domain_name,
"requirement_name": ns.get("requirement_name"),
"product_category": product_category,
"company_name": ns.get("company_name"),
"company_type": json.dumps(company_type) if isinstance(company_type, list) else company_type,
"contact_person": ns.get("contact_person"),
"job_title": ns.get("job_title"),
"phone_number": ns.get("phone_number"),
"email": ns.get("email"),
"cpu": ns.get("cpu"),
"memory": ns.get("memory"),
"gpu": ns.get("gpu"),
"sys_disk": ns.get("sys_disk"),
"data_disk": ns.get("data_disk"),
"net_card": ns.get("net_card"),
"price": ns.get("price"),
"priority": ns.get("priority") if ns.get("priority") else 1,
"status": ns.get("status") if ns.get("status") else '0',
"title": ns.get("title"),
"label": ns.get("label"),
"first_page": ns.get("first_page") if ns.get("first_page") else '0',
"requirement_summary": ns.get("requirement_summary"),
"related_parameters": ns.get("related_parameters"),
"application_scenario": ns.get("application_scenario"),
"audit_status": ns.get('audit_status', 'pending'),
}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
user_role = await get_user_role({'userid': userid, 'sor': sor})
# 非客户角色不需要审批
if user_role != '客户':
ns['status'] = '1'
ns_dic['audit_status'] = 'approved'
ns_dic['first_page'] = '1'
try:
await sor.C('user_publish_requirement', ns_dic)
return {