添加广告按gameid查询

This commit is contained in:
pengtao 2019-09-20 11:29:15 +08:00
parent 644ad943ea
commit 7d55b1f2e5

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,20 @@ 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,
@ -258,7 +220,7 @@ class Ad(Resource):
if not id:
return jsonify({'code': 404, 'message': f'{id} not found!'})
#del_sql = f"delete from ad where id={id};"
del_sql = f"update ad set status=4 where id={id};"
del_sql = f"update ad set in_used=0 where id={id};"
try:
self.mydb.change(del_sql)
return jsonify({'code': 200, 'message': f'remove adid={id} success!'})