From cb5f8adab20db6a4a8c815ef42d4d499a14f35a0 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 19 Jul 2019 15:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4ad=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index 2501ad1..b8d40a1 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -3,9 +3,9 @@ from __future__ import absolute_import """ 广告接口 -get (返回广告明细) params(gameid,localid)output(ad_title,ad_body,ad_image,ad_url) -post(新增广告定义) params(name,gameid,localid,start_time,end_time,ad_nums,ad_title,ad_body,ad_image,ad_url,ad_sort,status=unapproved,) output(1,0) -put(更新广告配置)params(name,gameid,localid,start_time,end_time,ad_nums,ad_title,ad_body,ad_image,ad_url,ad_sort)output(1,0) +get (返回广告明细) params(gameid,localid)output(ad_title,ad_body,ad_image,jump_param) +post(新增广告定义) params(name,gameid,localid,start_time,end_time,ad_nums,ad_title,ad_body,ad_image,jump_param,ad_sort,status=unapproved,) output(1,0) +put(更新广告配置)params(name,gameid,localid,start_time,end_time,ad_nums,ad_title,ad_body,ad_image,jump_param,ad_sort)output(1,0) delete(删除定义的广告)params()output(1,0) """ @@ -32,11 +32,11 @@ parser.add_argument('ad_num') parser.add_argument('ad_title') parser.add_argument('ad_body') parser.add_argument('ad_image') -parser.add_argument('ad_url') +parser.add_argument('jump_status') parser.add_argument('ad_sort') parser.add_argument('status') parser.add_argument('companyid') - +parser.add_argument('jump_param') class Ad(Resource): def __init__(self): @@ -54,16 +54,16 @@ class Ad(Resource): # 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,ad_url,ad_sort," \ + sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \ f"status,companyid,locationid,gameid from ad where 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,ad_url,ad_sort," \ + sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \ 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," \ + sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \ 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," \ + sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \ f"status,companyid,locationid,gameid from ad where id={id};" data = self.mydb.query(sel_sql) log.info(f"sql={sel_sql},data={data}") @@ -73,7 +73,7 @@ class Ad(Resource): for line in data: ad_info = {} 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_info['ad_title'], ad_info['ad_body'], ad_info['ad_image'], ad_info['jump_param'], ad_info[ 'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info[ 'gameid'] = line all.append(ad_info) @@ -97,13 +97,14 @@ class Ad(Resource): ad['ad_title'] = self.args['ad_title'] ad['ad_body'] = self.args['ad_body'] ad['ad_image'] = self.args['ad_image'] - ad['ad_url'] = self.args['ad_url'] + ad['jump_param'] = self.args['jump_param'] + ad['jump_status'] = self.args['jump_status'] ad['ad_sort'] = self.args['ad_sort'] or 0 ad['companyid'] = self.args['companyid'] # 检查必需有的字段 if not ( ad['name'] and ad['gameid'] and ad['locationid'] and ad['ad_title'] and ad['ad_body'] and ad['ad_image'] and - ad['ad_url'] and ad['companyid']): + ad['jump_param'] and ad['companyid']): return jsonify({'code': 500, 'message': '一些必填项未提供'}) # 检查该广告是否已存在 @@ -147,10 +148,11 @@ class Ad(Resource): ad['ad_title'] = self.args['ad_title'] ad['ad_body'] = self.args['ad_body'] ad['ad_image'] = self.args['ad_image'] - ad['ad_url'] = self.args['ad_url'] + ad['jump_param'] = self.args['jump_param'] ad['ad_sort'] = self.args['ad_sort'] ad['status'] = self.args['status'] or 0 ad['companyid'] = self.args['companyid'] + ad['jump_status'] = self.args['jump_status'] sel_sql = f"select name from ad where id={self.args['id']};" data = self.mydb.query(sel_sql)