添加广告按gameid查询

This commit is contained in:
pengtao 2019-09-20 11:38:55 +08:00
parent 1e3f4da52d
commit 7841c0a9b2

View File

@ -49,62 +49,14 @@ class Ad(Resource):
status = self.args['status']
id = self.args['id']
companyid = self.args['companyid']
gameid = self.args['gameid']
# if not gameid or not localid:
# # log.error(f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid}")
# return jsonify({'code': 500, "message": f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid},{status}"})
# now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
if not id:
if companyid:
sel_sql = f"""select
id,
name,
begin_time,
end_time,
ad_num,
ad_title,
ad_body,
ad_image,
jump_param,
ad_sort,
status,
companyid,
locationid,
gameid,
channelid,
jump_status,
ad_property
from
ad
where
in_used=1
and companyid={companyid};"""
elif status or status == 0:
sel_sql = f"""select
id,
name,
begin_time,
end_time,
ad_num,
ad_title,
ad_body,
ad_image,
jump_param,
ad_sort,
status,
companyid,
locationid,
gameid,
channelid,
jump_status,
ad_property
from
ad
where
in_used=1
and status={status};"""
else:
sel_sql = f"""select
base_sql = """SELECT
id,
name,
begin_time,
@ -122,10 +74,19 @@ class Ad(Resource):
channelid,
jump_status,
ad_property
from
FROM
ad
where
in_used=1 ;"""
WHERE
in_used=1 """
if companyid:
sel_sql = f"{base_sql} and companyid={companyid}"
else:
sel_sql = f"{base_sql}"
if status:
sel_sql = f"{sel_sql} and status={status}"
if gameid:
sel_sql = f"{sel_sql} and gameid={gameid}"
else:
sel_sql = f"""select
id,