问题描述
我正在使用connexion通过Flask创建REST API。目前,我正在传递一个标识符。
/read/maa_valid_product_id/{drug_product_id}:
get:
operationId: registrations.read_maa_valid_product_id
tags:
- Marketing Applications
summary: Read the entire list of non-passive marketing application registrations for a specified drug_product_id,which have a valid authorisation status
description: Read the entire list of non-passive marketing application registrations for a specified drug_product_id,which have a valid authorisation status
parameters:
- in: path
name: drug_product_id
required: true
schema:
type: integer
description: Numeric ID of the user to get
- in: query
name: length
required: false
schema:
type: integer
description: Numeric ID of the user to get
- in: query
name: offset
required: false
schema:
type: integer
description: Numeric ID of the user to get
responses:
'200':
description: Successfully commpleted the list operation for non-passive valid MAAs,for the specified drug_product_id
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/marketing_application'
我需要根据表中的选择传递一个id值数组。这可能吗?
如果可能,我将如何访问数组,现有方法调用为:
def read_maa_valid_product_id(drug_product_id,length=0,offset=0):
"""
This function responds to a request for /api/products
with the complete lists of people
:return: json string of list of people
"""
# conn_ariel = pool.acquire()
conn_ariel = get_connection()
cursor_ariel = conn_ariel.cursor()
# Create the list of products from our data
sql = """
SELECT A.DRUG_PRODUCT_ID,B.PREFERRED_TRADE_NAME,B.PRODUCT_LINE,B.PRODUCT_TYPE,B.FLAG_PASSIVE AS PRODUCT_FLAG_PASSIVE,A.REGISTRATION_UID,A.COUNTRY_DISPLAY_LABEL,A.FLAG_PASSIVE,A.AUTHORIZATION_STATUS,A.DISTRIBUTION_TYPE AS PROCEDURE_TYPE,A.MAH_COMPANY,A.DOSSIER_REF_NUMBER AS REGISTRATION_NAME_DETAILS,A.APPLICATION_STAGE,A.APPLICATION_TYPE,A.RENEWAL_NOT_REQUIRED,TO_CHAR(A.NEXT_RENEWAL_DATE,'YYYY-MM-DD') AS NEXT_RENEWAL_DATE
FROM DIM_REGISTRATION_SET A,DIM_DRUG_PRODUCT B,v_rep_az_183_01_reg_includes C
WHERE A.DRUG_PRODUCT_ID = B.DRUG_PRODUCT_ID AND A.VERSION_SEQ = C.VERSION_SEQ
AND A.DATA_STATE = 'C'
AND A.FLAG_PASSIVE = '0'
AND A.APPLICATION_TYPE = 'Marketing Application'
AND A.AUTHORIZATION_STATUS LIKE 'Valid%'
AND A.DRUG_PRODUCT_ID = :id
ORDER BY B.PREFERRED_TRADE_NAME,A.COUNTRY_DISPLAY_LABEL ASC
"""
cursor_ariel.execute(sql,{"id":drug_product_id})
registrations = []
names = [c[0] for c in cursor_ariel.description]
cursor_ariel.rowfactory = collections.namedtuple("registrations",names)
i = 0
j = 0
start = None
if offset == 0:
start = True
else:
start = False
for row in cursor_ariel.fetchall():
if start == True:
registration = {
"drug_product_id": row.DRUG_PRODUCT_ID,"preferred_trade_name": row.PREFERRED_TRADE_NAME,"product_line": row.PRODUCT_LINE,"product_type": row.PRODUCT_TYPE,"product_flag_passive": row.PRODUCT_FLAG_PASSIVE,"registration_uid": row.REGISTRATION_UID,"country_display_label": row.COUNTRY_DISPLAY_LABEL,"flag_passive": row.FLAG_PASSIVE,"authorization_status": row.AUTHORIZATION_STATUS,"procedure_type": row.PROCEDURE_TYPE,"mah_company": row.MAH_COMPANY,"registration_name_details": row.REGISTRATION_NAME_DETAILS,"application_stage": row.APPLICATION_STAGE,"application_type": row.APPLICATION_TYPE,"renewal_not_required": row.RENEWAL_NOT_REQUIRED,"next_renewal_date": row.NEXT_RENEWAL_DATE
}
# logging.info("Adding Registration: %r",registration)
registrations.append(registration)
if length > 0:
if i == length - 1:
break
i += 1
else:
if j == offset - 1:
start = True
j += 1
pool.release(conn_ariel)
return registrations
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)