updsate
This commit is contained in:
parent
0f76206df4
commit
ac6b65d800
@ -44,6 +44,7 @@ async def publish_product_add(ns={}):
|
|||||||
company_type = ns.get('company_type')
|
company_type = ns.get('company_type')
|
||||||
ns_dic = {
|
ns_dic = {
|
||||||
"id": uuid(),
|
"id": uuid(),
|
||||||
|
"publish_type": ns.get("publish_type"),
|
||||||
"orgid": orgid,
|
"orgid": orgid,
|
||||||
"img": ns.get('img'),
|
"img": ns.get('img'),
|
||||||
"domain_name": domain_name,
|
"domain_name": domain_name,
|
||||||
@ -62,6 +63,8 @@ async def publish_product_add(ns={}):
|
|||||||
"data_disk": ns.get("data_disk"),
|
"data_disk": ns.get("data_disk"),
|
||||||
"net_card": ns.get("net_card"),
|
"net_card": ns.get("net_card"),
|
||||||
"price": ns.get("price"),
|
"price": ns.get("price"),
|
||||||
|
"unit": ns.get("unit"),
|
||||||
|
"short_term": ns.get("short_term"),
|
||||||
"priority": ns.get("priority") if ns.get("priority") else 1,
|
"priority": ns.get("priority") if ns.get("priority") else 1,
|
||||||
"status": ns.get("status") if ns.get("status") else '0',
|
"status": ns.get("status") if ns.get("status") else '0',
|
||||||
"title": ns.get("title"),
|
"title": ns.get("title"),
|
||||||
@ -90,5 +93,6 @@ async def publish_product_add(ns={}):
|
|||||||
'msg': 'Failed to publish product, %s' % str(e)
|
'msg': 'Failed to publish product, %s' % str(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ret = await publish_product_add(params_kw)
|
ret = await publish_product_add(params_kw)
|
||||||
return ret
|
return ret
|
||||||
@ -6,6 +6,7 @@ async def publish_product_search_first_page(ns={}):
|
|||||||
:param ns:
|
:param ns:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
publish_type = ns.get('publish_type')
|
||||||
page_size = int(ns['page_size']) if ns.get('page_size') else 8
|
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_param = int(ns['current_page']) if ns.get('current_page') else 1
|
||||||
current_page = (current_page_param - 1) * page_size
|
current_page = (current_page_param - 1) * page_size
|
||||||
@ -20,14 +21,14 @@ async def publish_product_search_first_page(ns={}):
|
|||||||
try:
|
try:
|
||||||
ns['del_flg'] = '0'
|
ns['del_flg'] = '0'
|
||||||
if to_page == 'first_page':
|
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,)
|
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' ORDER BY uppc.priority ASC, upp.create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, page_size, current_page)
|
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:
|
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;"""
|
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' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (page_size, current_page)
|
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':
|
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,)
|
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' ORDER BY create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, page_size, current_page)
|
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:
|
else:
|
||||||
count_sql = ''
|
count_sql = ''
|
||||||
find_sql = ''
|
find_sql = ''
|
||||||
|
|||||||
@ -1,24 +1,61 @@
|
|||||||
async def requirement_add(ns={}):
|
async def requirement_add(ns={}):
|
||||||
product_category = ns.get('product_category')
|
if ns.get('userid'):
|
||||||
company_type = ns.get('company_type')
|
userid = ns.get('userid')
|
||||||
ns_dic = {
|
else:
|
||||||
'id': uuid(),
|
userid = await get_user()
|
||||||
'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')
|
|
||||||
}
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext('kboss') as sor:
|
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": 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'),
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
await sor.C('user_publish_requirement', ns_dic)
|
await sor.C('user_publish_requirement', ns_dic)
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user