添加按companyid返回广告列表的方法

This commit is contained in:
pengtao 2019-07-11 10:55:39 +08:00
parent 73c9b1ee2a
commit 71df5f75ee
2 changed files with 8 additions and 7 deletions

View File

@ -426,10 +426,11 @@ http://192.168.100.20:8888/ad?status=0
##### 请求参数说明
| 名称 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | --------------------------- |
| | int | 否 | 广告ID其优先级高于status |
| status | int | 否 | 审批状态默认为1已审批 |
| 名称 | 类型 | 必填 | 说明 |
| --------- | ---- | ---- | ---------------------------------- |
| id | int | 否 | 广告ID其优先级高于其他参数 |
| companyid | int | 否 | 公司ID优先级高于status |
| status | int | 否 | 审批状态,都不填写返回所有广告信息 |
##### 返回参数说明

View File

@ -56,8 +56,8 @@ class Ad(Resource):
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort," \
f"status,companyid from ad where companyid={companyid};"
elif status:
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort," \
f"statuscompanyid from ad where status={status};"
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort," \
f"statuscompanyid from ad where status={status};"
else:
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort," \
f"status,companyid from ad ;"
@ -73,7 +73,7 @@ class Ad(Resource):
for line in data:
ad_info['id'], ad_info['name'], ad_info['begin_time'], ad_info['end_time'], ad_info['ad_num'], \
ad_info['ad_title'], ad_info['ad_body'], ad_info['ad_image'], ad_info['ad_url'], ad_info[
'ad_sort'], ad_info['status'] = line
'ad_sort'], ad_info['status'], ad_info['companyid'] = line
all.append(ad_info)
return jsonify({'code': 200, 'message': all})
except Exception: