添加按companyid返回广告列表的方法
This commit is contained in:
parent
71df5f75ee
commit
94b3ef043e
@ -54,16 +54,16 @@ class Ad(Resource):
|
||||
if not id:
|
||||
if companyid:
|
||||
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};"
|
||||
f"status,companyid,locationid,gameid 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"status,companyid from ad where status={status};"
|
||||
f"status,companyid,locationid,gameid 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 ;"
|
||||
f"status,companyid,locationid,gameid from ad ;"
|
||||
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 where id={id};"
|
||||
f"status,companyid,locationid,gameid from ad where id={id};"
|
||||
data = mydb.query(sel_sql)
|
||||
log.info(f"sql={sel_sql},data={data}")
|
||||
if data:
|
||||
@ -72,15 +72,15 @@ class Ad(Resource):
|
||||
try:
|
||||
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'], ad_info['companyid'] = line
|
||||
ad_info['ad_title'], ad_info['ad_body'], ad_info['ad_image'], ad_info['ad_url'], ad_info['ad_sort'], \
|
||||
ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info['gameid'] = line
|
||||
all.append(ad_info)
|
||||
return jsonify({'code': 200, 'message': all})
|
||||
except Exception:
|
||||
log.error("split data from mysql failed!", exc_info=True)
|
||||
else:
|
||||
return jsonify({
|
||||
'code': 404, 'message': f'ad not found with id={id},status={status}!'
|
||||
'code': 404, 'message': f'ad not found with id={id},status={status},companyid={companyid}!'
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user