From a6ec54f42f774d91f4349c871d92f56a9c34a891 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 24 Jul 2019 19:43:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 220 ++------------------------------------------ handler/location.py | 17 +++- server.py | 1 + 3 files changed, 21 insertions(+), 217 deletions(-) diff --git a/README.MD b/README.MD index a93769f..7018ceb 100644 --- a/README.MD +++ b/README.MD @@ -196,12 +196,13 @@ http://154.8.214.202:5015/interface/location ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| --------- | ---- | ---- | --------------------------------------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 是 | 渠道ID,默认是6001 | -| area | int | 否 | 游戏区域 (1=首页,2=游戏中,3=结算页,4=关闭) | -| | int | 否 | 类型(1=icon,2=banner,3=浮窗) | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | ---- | ---- | --------------------------------------------- | +| gameid | int | 是 | 游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 | +| area | int | 是 | 游戏区域 (1=首页,2=游戏中,3=结算页,4=关闭) | +| type | int | 是 | 类型(1=icon,2=banner,3=浮窗,4=icon2) | +| localtionid | int | 是 | 位置ID | ##### 返回参数说明 @@ -560,210 +561,3 @@ http://154.8.214.202:5015/interface/area "code": 200 } -#### 14、变更区域 - -##### 接口地址 - -http://154.8.214.202:5015/interface/area - -##### 返回格式:json - -##### 请求方式:put - -##### 请求示范 - -http://154.8.214.202:5015/interface/area - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------------------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 是 | 渠道ID,默认为6001 | -| areaid | int | 是 | 区域ID | -| areaname | string | 是 | 区域说明 | -| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| | string | 是 | 区域示意图 | - -##### - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} - -#### 15、查询区域 - -##### 接口地址 - -http://154.8.214.202:5015/interface/area - -##### 返回格式:json - -##### 请求方式:get - -##### 请求示范 - -http://154.8.214.202:5015/interface/area - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ---- | ---- | ----------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID 默认为6001 | - -返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} - -#### 16、新建类型 - -##### 接口地址 - -http://154.8.214.202:5015/interface/type - -##### 返回格式:json - -##### 请求方式:post - -##### 请求示范 - -http://154.8.214.202:5015/interface/type - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------------------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID,默认为6001 | -| typeid | int | 是 | 类型ID | -| typename | string | 是 | 类型描述文字 | -| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| url | string | 是 | 类型示例图 | - -##### - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} - -#### 17、删除按钮类型 - -##### 接口地址 - -http://154.8.214.202:5015/interface/type - -##### 返回格式:json - -##### 请求方式:delete - -##### 请求示范 - -http://154.8.214.202:5015/interface/type - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------------- | -| id | int | 是 | 需删除的位置ID | - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} -#### 18、变更按钮类型 - -##### 接口地址 - -http://154.8.214.202:5015/interface/type - -##### 返回格式:json - -##### 请求方式:put - -##### 请求示范 - -http://154.8.214.202:5015/interface/type - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------------- | -| id | int | 是 | 需删除的位置ID | - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} -#### 19、查询按钮类型 - -##### 接口地址 - -http://154.8.214.202:5015/interface/type - -##### 返回格式:json - -##### 请求方式:get - -##### 请求示范 - -http://154.8.214.202:5015/interface/type - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ---- | ---- | ----------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID 默认为6001 | - - - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} \ No newline at end of file diff --git a/handler/location.py b/handler/location.py index ac9c444..37accfd 100644 --- a/handler/location.py +++ b/handler/location.py @@ -16,7 +16,8 @@ parser.add_argument('id') parser.add_argument('area') parser.add_argument('type') parser.add_argument('in_used') - +parser.add_argument('gameid') +parser.add_argument('channelid') class Location(Resource): def __init__(self): @@ -25,7 +26,10 @@ class Location(Resource): def get(self): - sql = f"select id,area,type from location where in_used=1;" + gameid = self.args['gameid'] + channelid = self.args['channelid'] or 6001 + sql = f"select gameid,channelid,id,area,type from location where gameid={gameid} and channelid={channelid} " \ + f"and in_used=1;" try: data = self.mydb.query(sql) except Exception: @@ -37,7 +41,8 @@ class Location(Resource): for line in data: if line: localtion = {} - localtion['id'], localtion['area'], localtion['type'] = line + localtion['gameid'], localtion['channelid'], localtion['id'], localtion['area'], localtion[ + 'type'] = line all_data.append(localtion) del localtion return jsonify({'code': 200, 'message': all_data}) @@ -51,6 +56,8 @@ class Location(Resource): location = {} location['area'] = self.args['area'] location['type'] = self.args['type'] + location['gameid'] = self.args['gameid'] + location['channelid'] = self.args['channelid'] or 6001 location['id'] = self.create_id() self.mydb.insert("location", location) except Exception: @@ -78,7 +85,9 @@ class Location(Resource): location['id'] = self.args['id'] location['area'] = self.args['area'] location['type'] = self.args['type'] - location['in_used'] = self.args['in_used'] or 0 + 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: diff --git a/server.py b/server.py index 7271616..d463000 100644 --- a/server.py +++ b/server.py @@ -24,5 +24,6 @@ api.add_resource(Location, '/interface/location') api.add_resource(Ad, '/interface/ad') api.add_resource(Cos_sdk, '/interface/cos_upload') + if __name__ == '__main__': app.run(host='0.0.0.0', debug=True, port=5015)