From df39e302a02fe9b664a4b472bc7ba7eee38dc935 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 12 Sep 2019 11:48:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4locationid=20=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E5=8C=BA=E5=9F=9F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 14 +++++++++----- handler/location.py | 23 ++++++++++++++--------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/README.MD b/README.MD index 4ef9d55..de80260 100644 --- a/README.MD +++ b/README.MD @@ -236,7 +236,7 @@ http://154.8.214.202:6015/interface/location?gameid=1001&area=2&type=1&mode=2&x= | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | | mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | | gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID,默认是6001 | +| channelid | int | 是 | 渠道ID | ##### 返回参数说明 @@ -268,13 +268,17 @@ http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 | 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ------------------------------------------------------------ | -| area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 | +| area | string | 是 | 区域(支持多值,表明页面位置| +|x|int|是|X轴坐标| +|y|int|是|y轴坐标| +|x_offset|int|是|X坐标偏移量| +|y_offset|int|是|Y坐标偏移量| | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | | mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | -| id | int | 是 | 位置ID | -| | int | 是 | 状态 0=未审批,1=审批通过,2=审批未通过,默认为1 | | gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID,默认是6001 | +| channelid | int | 是 | 渠道ID | +|in_used|int|否|是否使用,默认为1| + ##### 返回参数说明 diff --git a/handler/location.py b/handler/location.py index 13c1786..f54c872 100644 --- a/handler/location.py +++ b/handler/location.py @@ -87,9 +87,10 @@ class Location(Resource): location['type'] = self.args['type'] location['mode'] = self.args['mode'] location['gameid'] = self.args['gameid'] - location['channelid'] = self.args['channelid'] or 6001 + location['channelid'] = self.args['channelid'] location['id'] = self.create_id() - if location['area'] and location['type'] and location['mode'] and location['gameid'] : + if location['area'] and location['type'] and location['mode'] and location['gameid'] and location[ + 'channelid']: self.mydb.insert("location", location) return jsonify({'code': 200}) else: @@ -126,14 +127,18 @@ class Location(Resource): location['gameid'] = self.args['gameid'] location['channelid'] = self.args['channelid'] location['in_used'] = self.args['in_used'] or 1 - sel_sql = f"select area from location where id={self.args['id']};" - data = self.mydb.query(sel_sql) - if data: - condition = f"id='{self.args['id']}'" - self.mydb.update("location", location, condition) - return jsonify({'code': 200}) + if location['area'] and location['type'] and location['mode'] and location['gameid'] and location[ + 'channelid']: + sel_sql = f"select area from location where id={self.args['id']};" + data = self.mydb.query(sel_sql) + if data: + condition = f"id='{self.args['id']}'" + self.mydb.update("location", location, condition) + return jsonify({'code': 200}) + else: + return jsonify({'code': 404, 'message': f"{self.args['id']} not found in mysql!"}) else: - return jsonify({'code': 404, 'message': f"{self.args['id']} not found in mysql!"}) + return jsonify({'code': 500, 'message': f"someting not found in {self.args}!"}) except Exception: log.error("update values to location mysql failed!", exc_info=True) return jsonify({'code': 500})