From ed59f2b031ee4f42d2e22478ef7007472a76e9c6 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 12 Sep 2019 11:30:39 +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 | 7 +++++-- handler/location.py | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.MD b/README.MD index 8cceb40..56e03d3 100644 --- a/README.MD +++ b/README.MD @@ -228,8 +228,11 @@ http://154.8.214.202:5015/interface/location?gameid=1003&area=1,1,1&type=1&mode= | 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ------------------------------------------------------------ | -| area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 ,第四、五元素代表x, -y轴偏移量| +| 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=轮播) | | gameid | int | 是 | 游戏ID | diff --git a/handler/location.py b/handler/location.py index 54411d7..5a6bc15 100644 --- a/handler/location.py +++ b/handler/location.py @@ -14,6 +14,10 @@ log = logging.getLogger(__name__) parser = reqparse.RequestParser() parser.add_argument('id') parser.add_argument('area') +parser.add_argument('x') +parser.add_argument('y') +parser.add_argument('x_offset') +parser.add_argument('y_offset') parser.add_argument('type') parser.add_argument('mode') parser.add_argument('in_used') @@ -32,7 +36,23 @@ class Location(Resource): log.error("get data from location failed!", exc_info=True) return jsonify({"code": 500, "message": "PLS Input gameid!"}) channelid = self.args['channelid'] or 6001 - sql = f"select gameid,channelid,id,area,type,mode from location where gameid={gameid} and channelid={channelid} and in_used=1;" + sql = f"""select + gameid, + channelid, + id, + area, + x, + y, + x_offset, + y_offset, + type, + mode + from + location + where + gameid={gameid} + AND channelid={channelid} + and in_used=1;""" try: data = self.mydb.query(sql) except Exception: @@ -44,8 +64,9 @@ class Location(Resource): for line in data: if line: localtion = {} - localtion['gameid'], localtion['channelid'], localtion['id'], localtion['area'], localtion['type'], \ - localtion['mode'] = line + localtion['gameid'], localtion['channelid'], localtion['id'], localtion['area'], localtion['x'], \ + localtion['y'], localtion['x_offset'], localtion['y_offset'], localtion['type'], localtion[ + 'mode'] = line all_data.append(localtion) del localtion return jsonify({'code': 200, 'message': all_data}) @@ -55,13 +76,13 @@ class Location(Resource): def post(self): - """ - More Actions名称类型必填说明areastring是区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上typeint是类型(1=icon,2=banner,3=浮窗)modeint是广告单播或轮播模式(1=单播,2=轮播)gameidint是游戏IDchannelidint否渠道ID,默认是6001 - :return: - """ try: location = {} location['area'] = self.args['area'] + location['x'] = self.args['x'] + location['y'] = self.args['y'] + location['x_offset'] = self.args['x_offset'] + location['y_offset'] = self.args['y_offset'] location['type'] = self.args['type'] location['mode'] = self.args['mode'] location['gameid'] = self.args['gameid'] @@ -69,12 +90,12 @@ class Location(Resource): location['id'] = self.create_id() if location['area'] and location['type'] and location['mode'] and location['gameid'] : self.mydb.insert("location", location) + return jsonify({'code': 200}) else: return jsonify({'code': 500,"message":f"get args was area={location['area']},type={self.args['type']},mode={self.args['mode']},gameid={self.args['gameid']}"}) except Exception: log.error("set values to location mysql failed!", exc_info=True) return jsonify({'code': 500}) - return jsonify({'code': 200}) def create_id(self): @@ -95,6 +116,10 @@ class Location(Resource): location = {} location['id'] = self.args['id'] location['area'] = self.args['area'] + location['x'] = self.args['x'] + location['y'] = self.args['y'] + location['x_offset'] = self.args['x_offset'] + location['y_offset'] = self.args['y_offset'] location['type'] = self.args['type'] location['mode'] = self.args['mode'] location['gameid'] = self.args['gameid']