From 3ba71f721693408efec85649fc5743cc6dff1f19 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 24 Jul 2019 18:47:19 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 358 +++++++++++++++++++++++++++++++++++++++++++++------ ad_Readme.md | 4 +- 2 files changed, 324 insertions(+), 38 deletions(-) diff --git a/README.MD b/README.MD index 0841cd9..a93769f 100644 --- a/README.MD +++ b/README.MD @@ -2,11 +2,8 @@ TODO: -广告添加 own字段 -返回所有广告[status] -返回单条广告 -图片上传接口 +区域/类型 增删改检查的接口 @@ -14,7 +11,7 @@ TODO: ##### 接口地址 -http://192.168.100.20:8888/company +http://154.8.214.202:5015/interface/company ##### 返回格式:json @@ -24,7 +21,7 @@ http://192.168.100.20:8888/company http://154.8.214.202:5015/company -http://192.168.100.20:8888/company?status=0 +http://154.8.214.202:5015/interface/company?status=0 ##### 请求参数说明 @@ -76,7 +73,7 @@ http://192.168.100.20:8888/company?status=0 ##### 接口地址 -http://192.168.100.20:8888/company +http://154.8.214.202:5015/interface/company ##### 返回格式:json @@ -84,7 +81,7 @@ http://192.168.100.20:8888/company ##### 请求示范 -http://192.168.100.20:8888/company?name=kings&contact=pt&tel=1234 +http://154.8.214.202:5015/interface/company?name=kings&contact=pt&tel=1234 ##### 请求参数说明 @@ -112,7 +109,7 @@ http://192.168.100.20:8888/company?name=kings&contact=pt&tel=1234 ##### 接口地址 -http://192.168.100.20:8888/company +http://154.8.214.202:5015/interface/company ##### 返回格式:json @@ -120,7 +117,7 @@ http://192.168.100.20:8888/company ##### 请求示范 -http://192.168.100.20:8888/company?appid=zpoHY37u&appkey=undefined&contact=miles001&id=1006&name=kingsome&status=1&tel=17771&user=assd +http://154.8.214.202:5015/interface/company?appid=zpoHY37u&appkey=undefined&contact=miles001&id=1006&name=kingsome&status=1&tel=17771&user=assd ##### 请求参数说明 @@ -152,7 +149,7 @@ http://192.168.100.20:8888/company?appid=zpoHY37u&appkey=undefined&contact=miles ##### 接口地址 -http://192.168.100.20:8888/company +http://154.8.214.202:5015/interface/company ##### 返回格式:json @@ -160,7 +157,7 @@ http://192.168.100.20:8888/company ##### 请求示范 -http://192.168.100.20:8888/company?id=1006 +http://154.8.214.202:5015/interface/company?id=1006 ##### 请求参数说明 @@ -185,7 +182,7 @@ http://192.168.100.20:8888/company?id=1006 ##### 接口地址 -http://192.168.100.20:8888/location +http://154.8.214.202:5015/interface/location ##### 返回格式:json @@ -193,13 +190,18 @@ http://192.168.100.20:8888/location ##### 请求示范 -http://192.168.100.20:8888/location +http://154.8.214.202:5015/interface/location + +http://154.8.214.202:5015/interface/location ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | ------ | -| gameid | int | 是 | 游戏ID | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | --------------------------------------------- | +| gameid | int | 是 | 游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 | +| area | int | 否 | 游戏区域 (1=首页,2=游戏中,3=结算页,4=关闭) | +| | int | 否 | 类型(1=icon,2=banner,3=浮窗) | ##### 返回参数说明 @@ -226,7 +228,7 @@ http://192.168.100.20:8888/location ##### 接口地址 -http://192.168.100.20:8888/location +http://154.8.214.202:5015/interface/location ##### 返回格式:json @@ -234,15 +236,18 @@ http://192.168.100.20:8888/location ##### 请求示范 -http://192.168.100.20:8888/location?area=1&type=1&gameid=1003 +http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 + +http://154.8.214.202:5015/interface/location ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | ---------------------------------------- | -| area | int | 是 | 区域(1=首页,2=游戏中,3=结算页,4=关闭) | -| type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | -| | int | 是 | 游戏ID | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | ---------------------------------------- | +| area | int | 是 | 区域(1=首页,2=游戏中,3=结算页,4=关闭) | +| type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | +| gameid | int | 是 | 游戏ID | +| channelid | int | 否 | 渠道ID,默认是6001 | ##### 返回参数说明 @@ -260,7 +265,7 @@ http://192.168.100.20:8888/location?area=1&type=1&gameid=1003 ##### 接口地址 -http://192.168.100.20:8888/location +http://154.8.214.202:5015/interface/location ##### 返回格式:json @@ -268,7 +273,7 @@ http://192.168.100.20:8888/location ##### 请求示范 -http://192.168.100.20:8888/location?id=1002 +http://154.8.214.202:5015/interface/location?id=1002 ##### 请求参数说明 @@ -294,7 +299,7 @@ http://192.168.100.20:8888/location?id=1002 ##### 接口地址 -http://192.168.100.20:8888/ad +http://154.8.214.202:5015/interface/ad ##### 返回格式:json @@ -302,7 +307,7 @@ http://192.168.100.20:8888/ad ##### 请求示范 -http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 +http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 ##### 请求参数说明 @@ -310,6 +315,7 @@ http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&a | ---------- | -------- | ---- | --------------------------------------------------- | | name | string | 是 | 广告名称 | | gameid | int | 是 | 广告投放的游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 NEW | | locationid | int | 是 | 位置ID | | ad_title | string | 是 | 广告标题 | | ad_body | string | 是 | 广告正文 | @@ -338,7 +344,7 @@ http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&a ##### 接口地址 -http://192.168.100.20:8888/ad +http://154.8.214.202:5015/interface/ad ##### 返回格式:json @@ -346,7 +352,7 @@ http://192.168.100.20:8888/ad ##### 请求示范 -http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 +http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 ##### 请求参数说明 @@ -357,6 +363,7 @@ http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&a | id | int | 是 | 广告ID | | name | string | 是 | 广告名称 | | gameid | int | 是 | 广告投放的游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 NEW | | locationid | int | 是 | 位置ID | | ad_title | string | 是 | 广告标题 | | ad_body | string | 是 | 广告正文 | @@ -385,7 +392,7 @@ http://192.168.100.20:8888/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&a ##### 接口地址 -http://192.168.100.20:8888/ad +http://154.8.214.202:5015/interface/ad ##### 返回格式:json @@ -393,7 +400,7 @@ http://192.168.100.20:8888/ad ##### 请求示范 -http://192.168.100.20:8888/ad +http://154.8.214.202:5015/interface/ad ##### 请求参数说明 @@ -417,7 +424,7 @@ http://192.168.100.20:8888/ad ##### 接口地址 -http://192.168.100.20:8888/ad +http://154.8.214.202:5015/interface/ad ##### 返回格式:json @@ -425,11 +432,13 @@ http://192.168.100.20:8888/ad ##### 请求示范 -http://192.168.100.20:8888/ad?id=1002 -http://192.168.100.20:8888/ad?companyid=0 -http://192.168.100.20:8888/ad?status=0 +http://154.8.214.202:5015/interface/ad?id=1002 + +http://154.8.214.202:5015/interface/ad?companyid=0 + +http://154.8.214.202:5015/interface/ad?status=0 ##### 请求参数说明 @@ -481,3 +490,280 @@ http://192.168.100.20:8888/ad?status=0 } } + +#### 12、新建区域 + +##### 接口地址 + +http://154.8.214.202:5015/interface/area + +##### 返回格式:json + +##### 请求方式:post + +##### 请求示范 + +http://154.8.214.202:5015/interface/area + +##### 请求参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | --------------------------------------------------- | +| gameid | int | 是 | 游戏ID | +| channelid | int | 否 | 渠道ID,默认为6001 | +| areaid | int | 是 | 区域ID | +| | string | 是 | 区域说明 | +| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | +| | string | 是 | 区域示例图 | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------- | +| code | int | 是 | 返回状态 | + +##### 返回示例 + +{ + "code": 200 +} + +#### 13、删除区域 + +##### 接口地址 + +http://154.8.214.202:5015/interface/area + +##### 返回格式:json + +##### 请求方式:delete + +##### 请求示范 + +http://154.8.214.202:5015/interface/area + +##### 请求参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ---- | ---- | -------------- | +| areaid | int | 是 | 需删除的区域ID | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------- | +| code | int | 是 | 返回状态 | + +##### 返回示例 + +{ + "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/ad_Readme.md b/ad_Readme.md index 62f4109..40b362d 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -10,7 +10,7 @@ http://ad.kingsome.cn/webapp/index.php ##### 请求示范 -http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003:6001","locationid":1001} +http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} ##### 请求参数说明 @@ -18,7 +18,7 @@ http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003:60 | --------- | ---- | ---- | ---------------------------------- | | c | string | 是 | OPS通用接口标志 | | a | string | 是 | 方法定义 当前为getAdList | -| body | string | 是 | 参数体,JSON格式,gameid,locationid作为key | +| body | string | 是 | 参数体,JSON格式,gameid,channelid,locationid作为key | ##### 返回参数说明 From a6ec54f42f774d91f4349c871d92f56a9c34a891 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 24 Jul 2019 19:43:13 +0800 Subject: [PATCH 02/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=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) From 1cb13e00edca869eccebb9d161173628712e7419 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 24 Jul 2019 19:52:03 +0800 Subject: [PATCH 03/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=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 | 23 +++++++++-------------- handler/location.py | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.MD b/README.MD index 7018ceb..18d3864 100644 --- a/README.MD +++ b/README.MD @@ -192,17 +192,14 @@ http://154.8.214.202:5015/interface/location http://154.8.214.202:5015/interface/location -http://154.8.214.202:5015/interface/location - ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ----------- | ---- | ---- | --------------------------------------------- | -| 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 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | --------------------------------------------- | +| gameid | int | 是 | 游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 | +| area | int | 否 | 游戏区域 (1=首页,2=游戏中,3=结算页,4=关闭) | +| type | int | 否 | 类型(1=icon,2=banner,3=浮窗,4=icon2) | ##### 返回参数说明 @@ -239,8 +236,6 @@ http://154.8.214.202:5015/interface/location http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 -http://154.8.214.202:5015/interface/location - ##### 请求参数说明 | 名称 | 类型 | 必填 | 说明 | @@ -278,9 +273,9 @@ http://154.8.214.202:5015/interface/location?id=1002 ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------------- | -| id | int | 是 | 需删除的位置ID | +| 名称 | 类型 | 必填 | 说明 | +| ---------- | ---- | ---- | -------------- | +| locationid | int | 是 | 需删除的位置ID | ##### 返回参数说明 diff --git a/handler/location.py b/handler/location.py index 37accfd..03174c9 100644 --- a/handler/location.py +++ b/handler/location.py @@ -48,7 +48,7 @@ class Location(Resource): return jsonify({'code': 200, 'message': all_data}) else: log.error(f"{data} not found in mysql !") - return jsonify({'code': 404}) + return jsonify({'code': 200, 'message': ""}) def post(self): From 92f9cac585674366d99371f1fdcbf2b258ccd8c5 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 11:43:34 +0800 Subject: [PATCH 04/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=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 | 147 +++++++++++++++++--------------------------- handler/location.py | 16 +++-- 2 files changed, 69 insertions(+), 94 deletions(-) diff --git a/README.MD b/README.MD index 18d3864..90c87a9 100644 --- a/README.MD +++ b/README.MD @@ -194,12 +194,10 @@ http://154.8.214.202:5015/interface/location ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| --------- | ---- | ---- | --------------------------------------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 是 | 渠道ID,默认是6001 | -| area | int | 否 | 游戏区域 (1=首页,2=游戏中,3=结算页,4=关闭) | -| type | int | 否 | 类型(1=icon,2=banner,3=浮窗,4=icon2) | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | ------------------ | +| gameid | int | 是 | 游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 | ##### 返回参数说明 @@ -238,12 +236,13 @@ http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| --------- | ---- | ---- | ---------------------------------------- | -| area | int | 是 | 区域(1=首页,2=游戏中,3=结算页,4=关闭) | -| type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | -| gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID,默认是6001 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------------------------------------ | +| area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 | +| type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | +| | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | +| gameid | int | 是 | 游戏ID | +| channelid | int | 否 | 渠道ID,默认是6001 | ##### 返回参数说明 @@ -257,7 +256,45 @@ http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 "code": 200 } -#### 7、删除位置服务信息 +#### 7、变更位置服务信息 + +##### 接口地址 + +http://154.8.214.202:5015/interface/location + +##### 返回格式:json + +##### 请求方式:put + +##### 请求示范 + +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)代表首页左上 | +| 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 | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------- | +| code | int | 是 | 返回状态 | + +##### 返回示例 + +{ + "code": 200 +} + +#### 8、删除位置服务信息 ##### 接口地址 @@ -273,9 +310,9 @@ http://154.8.214.202:5015/interface/location?id=1002 ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ---------- | ---- | ---- | -------------- | -| locationid | int | 是 | 需删除的位置ID | +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------------- | +| id | int | 是 | 需删除的位置ID | ##### 返回参数说明 @@ -291,7 +328,7 @@ http://154.8.214.202:5015/interface/location?id=1002 -#### 8、添加广告信息 +#### 9、添加广告信息 ##### 接口地址 @@ -336,7 +373,7 @@ http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_titl "code": 200 } -#### 9、变更广告信息(审批) +#### 10、变更广告信息(审批) ##### 接口地址 @@ -384,7 +421,7 @@ http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_titl "code": 200 } -#### 10、删除广告信息 +#### 11、删除广告信息 ##### 接口地址 @@ -416,7 +453,7 @@ http://154.8.214.202:5015/interface/ad "code": 200 } -#### 11、返回广告列表信息 +#### 12、返回广告列表信息 ##### 接口地址 @@ -486,73 +523,3 @@ http://154.8.214.202:5015/interface/ad?status=0 } } - -#### 12、新建区域 - -##### 接口地址 - -http://154.8.214.202:5015/interface/area - -##### 返回格式:json - -##### 请求方式:post - -##### 请求示范 - -http://154.8.214.202:5015/interface/area - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------------------------- | -| gameid | int | 是 | 游戏ID | -| channelid | int | 否 | 渠道ID,默认为6001 | -| areaid | int | 是 | 区域ID | -| | string | 是 | 区域说明 | -| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| | string | 是 | 区域示例图 | - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} - -#### 13、删除区域 - -##### 接口地址 - -http://154.8.214.202:5015/interface/area - -##### 返回格式:json - -##### 请求方式:delete - -##### 请求示范 - -http://154.8.214.202:5015/interface/area - -##### 请求参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | -------------- | -| areaid | int | 是 | 需删除的区域ID | - -##### 返回参数说明 - -| 名称 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | -------- | -| code | int | 是 | 返回状态 | - -##### 返回示例 - -{ - "code": 200 -} - diff --git a/handler/location.py b/handler/location.py index 03174c9..99bcd91 100644 --- a/handler/location.py +++ b/handler/location.py @@ -15,6 +15,7 @@ parser = reqparse.RequestParser() parser.add_argument('id') parser.add_argument('area') parser.add_argument('type') +parser.add_argument('mode') parser.add_argument('in_used') parser.add_argument('gameid') parser.add_argument('channelid') @@ -28,8 +29,8 @@ class Location(Resource): def get(self): 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;" + sql = f"select gameid,channelid,id,area,type,mode from location where gameid={gameid} and \ + channelid={channelid} and in_used=1;" try: data = self.mydb.query(sql) except Exception: @@ -41,8 +42,8 @@ class Location(Resource): for line in data: if line: localtion = {} - localtion['gameid'], localtion['channelid'], localtion['id'], localtion['area'], localtion[ - 'type'] = line + localtion['gameid'], localtion['channelid'], localtion['id'], localtion['area'], localtion['type'], \ + localtion['mode'] = line all_data.append(localtion) del localtion return jsonify({'code': 200, 'message': all_data}) @@ -52,12 +53,18 @@ 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['type'] = self.args['type'] + location['mode'] = self.args['mode'] location['gameid'] = self.args['gameid'] location['channelid'] = self.args['channelid'] or 6001 + location['id'] = self.create_id() self.mydb.insert("location", location) except Exception: @@ -85,6 +92,7 @@ class Location(Resource): location['id'] = self.args['id'] location['area'] = self.args['area'] location['type'] = self.args['type'] + location['mode'] = self.args['mode'] location['gameid'] = self.args['gameid'] location['channelid'] = self.args['channelid'] location['in_used'] = self.args['in_used'] or 1 From 28fc7a72acd4321c7ac82b3347e0f2971b125d59 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 11:49:01 +0800 Subject: [PATCH 05/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/location.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/handler/location.py b/handler/location.py index 99bcd91..fc6ca56 100644 --- a/handler/location.py +++ b/handler/location.py @@ -32,6 +32,7 @@ class Location(Resource): sql = f"select gameid,channelid,id,area,type,mode from location where gameid={gameid} and \ channelid={channelid} and in_used=1;" try: + print(f"1 {sql}") data = self.mydb.query(sql) except Exception: log.error("get data from location failed!", exc_info=True) @@ -39,6 +40,7 @@ class Location(Resource): all_data = [] log.debug(f"get data from localtion was {data}") if data: + pdb.set_trace() for line in data: if line: localtion = {} From 57e20163344bdf77025bd35adf81a51713c50d9d Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 14:39:02 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=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 | 70 ++++++++++++++++++++++++----------------- ad_interface_tornado.py | 16 +++++----- handler/location.py | 8 ++--- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/README.MD b/README.MD index 90c87a9..7b3c202 100644 --- a/README.MD +++ b/README.MD @@ -190,7 +190,7 @@ http://154.8.214.202:5015/interface/location ##### 请求示范 -http://154.8.214.202:5015/interface/location +http://154.8.214.202:5015/interface/location?gameid=1004 ##### 请求参数说明 @@ -209,15 +209,29 @@ http://154.8.214.202:5015/interface/location ##### 返回示例 { - "code": 200, - "message": [ - { - "area": 1, - "gameid": 1003, - "id": 1001, - "type": 1 - } - ] + + "code": 200, + + "message": [ + + { + +​ "area": "1,1,.1", + +​ "channelid": 6001, + +​ "gameid": 1003, + +​ "id": 1010, + +​ "mode": 2, + +​ "type": 1 + +​ } + + ] + } #### 6、添加位置服务信息 @@ -232,7 +246,7 @@ http://154.8.214.202:5015/interface/location ##### 请求示范 -http://154.8.214.202:5015/interface/location?area=1&type=1&gameid=1003 +http://154.8.214.202:5015/interface/location?gameid=1003&area=1,1,.1&type=1&mode=2 ##### 请求参数说明 @@ -240,7 +254,7 @@ 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)代表首页左上 | | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | -| | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | +| mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | | gameid | int | 是 | 游戏ID | | channelid | int | 否 | 渠道ID,默认是6001 | @@ -344,22 +358,22 @@ http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_titl ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ---------- | -------- | ---- | --------------------------------------------------- | -| name | string | 是 | 广告名称 | -| gameid | int | 是 | 广告投放的游戏ID | -| channelid | int | 是 | 渠道ID,默认是6001 NEW | -| locationid | int | 是 | 位置ID | -| ad_title | string | 是 | 广告标题 | -| ad_body | string | 是 | 广告正文 | -| ad_image | string | 是 | 头像链接 | -| ad_url | string | 是 | 跳转链接 | -| begin_time | datetime | 否 | 开始时间,默认是1999-01-01 | -| end_time | datetime | 否 | 结束时间,默认是3000-01-01 | -| ad_num | int | 否 | 投放次数,默认是0(次数无限) | -| ad_sort | int | 否 | 优先级默认为0 | -| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| companyid | int | 是 | 广告提交公司 | +| 名称 | 类型 | 必填 | 说明 | +| ---------- | -------- | ---- | ------------------------------------------------------- | +| name | string | 是 | 广告名称 | +| gameid | int | 是 | 广告投放的游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 NEW | +| locationid | int | 是 | 位置ID,通过该ID到localtion表中获得area,type,mode信息 | +| ad_title | string | 是 | 广告标题 | +| ad_body | string | 是 | 广告正文 | +| ad_image | string | 是 | 头像链接 | +| ad_url | string | 是 | 跳转链接 | +| begin_time | datetime | 否 | 开始时间,默认是1999-01-01 | +| end_time | datetime | 否 | 结束时间,默认是3000-01-01 | +| ad_num | int | 否 | 投放次数,默认是0(次数无限) | +| ad_sort | int | 否 | 优先级默认为0 | +| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | +| companyid | int | 是 | 广告提交公司 | ##### 返回参数说明 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index ad9edfe..bd28666 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,7 +28,9 @@ def send_cache_data(): now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] # 添加无天数限定的记录 - get_full_data = f"select id,name,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort,companyid,locationid,gameid,jump_status from ad where begin_time='{BEGIN}' or end_time='{END}'" + get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \ + f"a.companyid,a.gameid,a.jump_status,b.area,b.type,b.mode from ad a,location b where \ + a.locationid=b.id AND begin_time='{BEGIN}' or end_time='{END}'""" full_data = mydb.query(get_full_data) if full_data: @@ -38,15 +40,16 @@ def send_cache_data(): item = {} try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - 'jump_param'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[ - 'jump_status'] = line + 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['jump_status'], item[ + 'area'], item['type'], item['mode'] = line all.append(item) except Exception: log.error("split data failed", exc_info=True) # 添加有天数限定的记录 - get_data_sql = f"select id,name,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort,companyid,locationid,gameid," \ - f"jump_status from ad where '{now}'>begin_time and '{now}'a.begin_time and '{now}' Date: Thu, 25 Jul 2019 14:42:41 +0800 Subject: [PATCH 07/47] a --- handler/location.py | 1 - 1 file changed, 1 deletion(-) diff --git a/handler/location.py b/handler/location.py index fc6ca56..f3ec820 100644 --- a/handler/location.py +++ b/handler/location.py @@ -40,7 +40,6 @@ class Location(Resource): all_data = [] log.debug(f"get data from localtion was {data}") if data: - pdb.set_trace() for line in data: if line: localtion = {} From 83bd7d297189ef1cde299510f813fb1d6be68cb6 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 14:44:09 +0800 Subject: [PATCH 08/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index bd28666..7a572ea 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -90,7 +90,7 @@ def send_cache_data(): if not my_redis.exists(f"ad::{line['id']}::info"): # remove some filed from adinfo - remove_list = ('ad_num', 'companyid', 'gameid', 'locationid') + remove_list = ('ad_num', 'companyid', 'gameid') for item in remove_list: line.pop(item) my_redis.hmset(f"ad::{line['id']}::info", line) From 34ee45b8b0f7a99c52c76e2731452f42e09c29d8 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:18:22 +0800 Subject: [PATCH 09/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 14 ++++++++------ handler/ad.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 7a572ea..f0cc1bd 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -29,7 +29,7 @@ def send_cache_data(): all = [] # 添加无天数限定的记录 get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \ - f"a.companyid,a.gameid,a.jump_status,b.area,b.type,b.mode from ad a,location b where \ + f"a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where \ a.locationid=b.id AND begin_time='{BEGIN}' or end_time='{END}'""" full_data = mydb.query(get_full_data) @@ -40,15 +40,15 @@ def send_cache_data(): item = {} try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['jump_status'], item[ - 'area'], item['type'], item['mode'] = line + 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ + 'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line all.append(item) except Exception: log.error("split data failed", exc_info=True) # 添加有天数限定的记录 get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,\ - a.ad_sort,a.companyid,a.gameid,a.jump_status,b.area,b.type,b.mode from ad a ,location b \ + a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a ,location b \ where'{now}'>a.begin_time and '{now}' 0: num = my_redis.get(f"ad::{line['id']}::num") diff --git a/handler/ad.py b/handler/ad.py index f34f8f6..3b56a25 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -24,6 +24,7 @@ log = logging.getLogger(__name__) parser = reqparse.RequestParser() parser.add_argument('id') parser.add_argument('gameid') +parser.add_argument('channelid') parser.add_argument('name') parser.add_argument('locationid') parser.add_argument('begin_time') @@ -55,16 +56,16 @@ class Ad(Resource): 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," \ - f"status,companyid,locationid,gameid,jump_status from ad where companyid={companyid};" + f"status,companyid,locationid,gameid,channelid,jump_status 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,jump_param,ad_sort," \ - f"status,companyid,locationid,gameid,jump_status from ad where status={status};" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where status={status};" else: 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,jump_status from ad ;" + f"status,companyid,locationid,gameid,channelid,jump_status from ad ;" else: 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,jump_status from ad where id={id};" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where id={id};" data = self.mydb.query(sel_sql) log.info(f"sql={sel_sql},data={data}") if data: @@ -75,7 +76,7 @@ class Ad(Resource): 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['jump_param'], ad_info[ 'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info[ - 'gameid'],ad_info['jump_status'] = line + 'gameid'],ad_info['channelid'],ad_info['jump_status'] = line all.append(ad_info) return jsonify({'code': 200, 'message': all}) except Exception: @@ -90,6 +91,7 @@ class Ad(Resource): ad['id'] = id ad['name'] = self.args['name'] ad['gameid'] = self.args['gameid'] + ad['channelid'] = self.args['channelid'] ad['locationid'] = self.args['locationid'] ad['begin_time'] = self.args['begin_time'] or '1999-01-01' ad['end_time'] = self.args['end_time'] or '3000-01-01' @@ -140,6 +142,7 @@ class Ad(Resource): ad['id'] = self.args['id'] ad['name'] = self.args['name'] ad['gameid'] = self.args['gameid'] + ad['channelid'] = self.args['channelid'] ad['locationid'] = self.args['locationid'] ad['begin_time'] = self.args['begin_time'] or '1999-01-01' ad['end_time'] = self.args['end_time'] or '3000-01-01' From 1813fc5cebcccebd309229f22dd044b3bb9898f7 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:20:26 +0800 Subject: [PATCH 10/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index f0cc1bd..bf08109 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -67,7 +67,7 @@ def send_cache_data(): if all: # log.info(f"get data was {all}!\n") for line in all: - key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0]}\ + key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}\ ::{line.get('locationid', 0)}" if int(line['ad_num']) > 0: From d87f3b502440a0a35ca27231a12903d9a48ea70f Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:24:38 +0800 Subject: [PATCH 11/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index bf08109..17d42eb 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -66,6 +66,7 @@ def send_cache_data(): # 检查ID是否存在播放列表中,以及播放次数是否完毕 if all: # log.info(f"get data was {all}!\n") + pdb.set_trace() for line in all: key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}\ ::{line.get('locationid', 0)}" From af3e46e280f2a26cf259945c9d75140f6ff9b76b Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:27:55 +0800 Subject: [PATCH 12/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 17d42eb..2814bb5 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -66,11 +66,8 @@ def send_cache_data(): # 检查ID是否存在播放列表中,以及播放次数是否完毕 if all: # log.info(f"get data was {all}!\n") - pdb.set_trace() for line in all: - key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}\ - ::{line.get('locationid', 0)}" - + key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}::{line.get('locationid', 0)}" if int(line['ad_num']) > 0: num = my_redis.get(f"ad::{line['id']}::num") if not num: From 3a88d82526a527222fc701015786e1ac741c38ad Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:33:21 +0800 Subject: [PATCH 13/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 2814bb5..99dd235 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -151,15 +151,17 @@ class DispatchHandler(tornado.web.RequestHandler): try: input = json.loads(self.get_query_argument('body')) gameid = input['gameid'] - locationid = input['locationid'] + channelid=input['channelid'] + area=input.get('locationid',0) + locationid = input.get('locationid',0) except Exception as e: result = {'errcode': 2, "errmsg": f"get args failed,{str(e)}"} log.error(result) self.write_error(2) return False - if gameid and locationid: - key = f"ad::{gameid}::{locationid}" - + if gameid and channelid and locationid: + key = f"ad::{gameid}::{channelid}::*::{locationid}" + pdb.set_trace() ids = my_redis.smembers(key) info = [] if not ids: From 541ab3b4cb8c824d03f87a0769446f9082458f8e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Jul 2019 15:33:47 +0800 Subject: [PATCH 14/47] a --- __pycache__/config.cpython-36.pyc | Bin 312 -> 672 bytes handler/__pycache__/__init__.cpython-36.pyc | Bin 122 -> 122 bytes handler/__pycache__/company.cpython-36.pyc | Bin 4245 -> 4476 bytes handler/__pycache__/location.cpython-36.pyc | Bin 3358 -> 4120 bytes log/__pycache__/__init__.cpython-36.pyc | Bin 118 -> 118 bytes log/__pycache__/mylog.cpython-36.pyc | Bin 721 -> 721 bytes myredis/__pycache__/__init__.cpython-36.pyc | Bin 122 -> 122 bytes myredis/__pycache__/myredis.cpython-36.pyc | Bin 487 -> 508 bytes mysql/__pycache__/__init__.cpython-36.pyc | Bin 120 -> 120 bytes mysql/__pycache__/mmysql.cpython-36.pyc | Bin 4100 -> 4086 bytes 10 files changed, 0 insertions(+), 0 deletions(-) diff --git a/__pycache__/config.cpython-36.pyc b/__pycache__/config.cpython-36.pyc index fdde27bf1943a883f6aec526660ce228c6552ec7..741e2f80ae9adce1dfdb8d40c47762955aba8b6a 100644 GIT binary patch literal 672 zcmY*WO>fgM7`C0XP1CguHp-YlD&o{b({$luK?tFVYU0uhaEXMftgqXerAe^8t?iNV z3pjA%5Ac_KYYy0u@zJ46k>+ZWRo%a)qkRRlqR>Jrt4)qxU2+)K? zgp&^x*fovVIW5LMxBi@lAyH{260V|hta3im|FZ($ z*qST7e0bV_+Ztu*SWH@1LQh+>h5DFuB?qBe;}{j-foR<$M10-Dhq%2k3_E@g`_c`3 z-`~XTnqiqT)**sw5Xf2}wiWwSg^7dRIgO>;|-*(}o{OaJUw`|}ac ziyc$r^IS+i)MCa>6Ezc|^iZUl%W*v7!?kmzlm6-JfwB67SKo<5+c)s*eivdLcPB!3 r@pCpgx|`fyzA(=7Sq2vge^C^y4iOyYQkOZjL3imInZs;mQ=9$<+uppC delta 227 zcmZ3$x`V0Sn3tF9`B$abK1K$H#|%h-707k~;$kHrk;0I|n8K98Jcl`oA%!K1F@-gS zErmUWBZYGgOB7QIS1^MncNL$ZrIDVYnT4LAfq|ZpLFQ`-28NeFV;MA=Z?Rxy6){l&K)Yz!1fnn>jg@QBhixk delta 13 Ucmb=bVmIdH<+}e+X(D?u02{yrKmY&$ diff --git a/handler/__pycache__/company.cpython-36.pyc b/handler/__pycache__/company.cpython-36.pyc index 2ffe3005c32d65c6c5dcbb8659b97bb3deff9acf..2965e3bda3094796e98f026e44f0deff813c91dd 100644 GIT binary patch literal 4476 zcmb_fOOG5^6~6WC>gPN?V}~TvB*K$6gNHx}61GX=@De1WC_%z05w&Xi-X2%Gs;hmg z+IE*}*o?Oz7A%m0w@Cbl`~bufAr^Owgz%n~SA6GIcg;hyKuWq*r_O!Xz2|)2IrqEW zZtFi^eCxA!RvG&jJM*)lzl$gPI|OIkh*@F;hC#X+n~4=zi5=LwY{gFE25!;_8i^Np zNi%5bdOL0fE%bNdcG3wty3UQeNiXOv+E;=V(HgIcwG$&)7w&lDgaw;ob9{w2POz5N zyjpA4TC3LDwbrS%Zmso5`zhlqeDx{gtD<>g1zX(yg!R{+V_&RqsFm0Eh(K{Sc-!Qg8cm64Y+qh%DUi!Z;qY_7LJ>#pI^TlfJs zRI)ML`5HUMr$aNLnOd`;Sx4;Hp8umXzb|7k^yg& z7HT}*$L7sr2QwLCvvf|3V>h?PHgA>g=j@qDj##?#pHK4A{So`@gX2cokWV9a?3ImQ zd!@(C+YGX;Wk<`dmOU+3v^2D|AnmbJYGC}vd-(KMZ1O6tMJw^uYOUPmYe$T){|PI9 z!qDR_o8^rMt=}8+h5@@83?n?gq4&7?%;H!0)^APJx_p~ojSL!fk4kH$y_}_g?LdMj zm~4|+hbRtULov+#i0_eG?=8G~58k_{9h)TldarWpJ#uJ&1X%bBoBEIM3n~1n`OXXD zR`K(%Xv&D+DL(v)=AzHOvs;+Ew~D)8ddgeHl_Qb+k zRv?Ni{v^%)Q97G&KbrWOT>PEqe?=SU${wa1gp!CX3y(yxL6a{}cX6&o(;tOVEclN9 zOCZk^PlkZeD3z~bis-*UMZYPxXuWL+U*0b((7TTKHaD5o?qf0>&a1{PpUR6qdM zfCX&61K3y(TJqikGyvWyF>seR7N7yqo&k-=TUDvwKG0|>Uf}>rE-v$ZII4UZUsN=t zNYY2bFTAC-U@YmQ>C{g06%_l8Q)9^;YX1g_*GOC^L1yY(l~HKdV15w~V1$e3?N*=l z9{OZtJvwsJ=-?=O)nWFQhgo%e?xD}nq@MWEGW6&}y#WQ0h{fPj{Wgv*ZqiYXt&-Tu z8avypG)^=l^{oR5w_}P?)Q}+hG@;-pqX~R&oJJFr!ekl?)eW;@6b*2ExsaK1d4wpD z^=-X9Wld&@yos6QJ_!mYXZ)!J9~e}#{{k(U3&9Kz|6+Z)v(qlMx6r1@WAw(p4TZer z1R;YP+EdK)o^p&0%02Y4PC%?Bs1w^Ob{9;cdGIpB>xMhKFN|Gm=6hI0qfZ-DHR-E# zhs8!U9R%&+eKCAcHOO5Wa(=_|`>6W}Pex>dothn3)298do!zgV`P_DEa6G~|ZdB26 zjO`+lnK^6-kRbY1(Pe%kw@Z^FV$ySBaC;lEQ}=RoM0B576!8F{>j01g08JMFGRFW7 zGk}HrII6Z9L^DGd@iz~A4f@)`)?NJo4$6W=j2UA zI|-jq7vj?w#!m5)<|qGgl;8JpqBSp~%Mx4Bb66UPBIc{Wq;d2*ipq*6d4(;4)xr|U zbi*fui0kuL777=Ppt@wdVU@H*{8J3gHX#@cLC`XdO%1Ldz*by2YnFOUZ5o1FZJIx$ zFrOf4s8SasF(o__>A)h9L5b1`D#0u$QK~>CTbFEIqWsO^j@C`BySEt<8H0Pej*^xp z!Bm^?#=?AmT$s-tHz=9p9nE_l@A6*FdsJFk@ZRdd#c)RXLX|mCU{g&5GciIe;5x?1 zJ}QgXGuY@+7|%rJ=V@)ND&Q?5*wStnIdKudZqqV^f-01`(FC!3VZ;jrX;uVDD_^vr zJx#NGgoccmnJofP53JaO2|K{ky4DeHI!go6klJnzM%8w^3g4Xn`%Bslsi?MMWjV&( zYixQ?+YR>9R`zszWktrDy3~YiTe=nAg7mO`33L68ch2NIn&@)x9;>t{S>vraE*p6#W_=zGJ}DnefBE;^wgV4q2bURy8( z<(ua@qDm#}aB4%_m6S+m=hFV7!)NpdOj&GRl2q;V&8pkiF{-#en<8Zq|F1(!NE~(^>u)U9vYI&ULF26}a2PzFP z4YhZu?kbZdW`mLARWnZ(kP_)a+^x`0cH zz*WZC)fEFN0Lob`30#swxonW2oJ2K{tR5kG2s)ZAZYKJrubs-RuHX9l8CX+(sKe_A z7=Z9VF$YqQ6?j PU(+*NrU$Y=_qYECPD2v< delta 2216 zcmZWq&2Jk;6rb5|uh$<*9J@(NNh=z%X`7bPB1F?lrAbjyRZt5B46SiJ>vSD|b#{a5 zXk8<@NJt1onZl*y1Q)KH`X_MUggEVm6NgHGIB=>s@ZPL(qSUK-esA8)?7ZK5@3;RR z{Q7|XVkTpEzdCgNuk3w$IB@F3%YH%2Q=ZW%3`u#~n{E`DIi!?G%^GW|v1X68^jLGo zS_ZY(2+OkEJ;HKcYN(b=OuI_l{9^(?m&Up3&7jlV2)&AM=zZ}W{di6R&v_U@7DPxI zbVwpnQ5b=J^s=jpH8~UBLYw;q?jP5AjGZt1$XiKpN z*Q#q?xDS-zI0!;*cr>cO$l_2mYAbora8^^6;NJo}FMc)_PcYaJkp^LOhV*G~mMIcD z6^cNS$(G3lq)!0S>blLZiAD3qU>3G*n%rx3KJw-^t+{&DZ+h&&TQ22z5gES3gFgeN zYs&cfv*?;baR|i$6wjf+h+Q=a6SGh@nb)iYx0^|j+mRYD?}gsvE3hcQq+zrQb!b-1 zSl=H*oMN@T(c(uz<4Y)ZVPykW6<%$#PHRQ{VZA($ix7b!#LuXVUfCIaUyW40C@!VW zzJC(W8wU}m@F+-~&s;6JJGN{&UAyJg))NPxfBFjiC78PiBXB?vNQOgg@q2116@tlV zpN3+;eTlZky8U2)aQcr`3F7$G33La+6{~(bOyEQ$M;9p@t?HeM&*bZ46^z|5Wbp2_ zgeQD<1-1qS5JZ+q9w05yB9u>7+)W=hz5z$?hG=G97$6%_ra`Nch9Y%+nJ@$9%w=po zjad;LLd!wPEJDfXP%@v6TGMElEX8b=mMv*9hh@esiB>kT+}vf3$nXq`2^3fp9KjVm zXM!$>&zvI?nB8@j^cg>m%MoRntl03|fyYNE?J7DYN!$W1-c>1Dw-baFa0FQGWYkcA z36z^dRSP=kbmp*OK-c$v1#ngd-Pa`&fQW1jT%=`53pkLaqzw%Rv}Qk5YL8fY zhu=XqhDKCbCZfQ+Dv+7BO@W~2$E)8aY+_4clgMk59gidl0Ctqz2wO1)Q>?(IWeV`1 z;{Pd-9~huQiS-Wr#l!4!QTDs$vop{0QwWvBYp?h-J8vM<@%>^ZcdR696f4Z)P56k(KF2Bx3?v+&`>*FlWokOvm_c77%NpK*yN|LdtrCR$f+t#g=m9g^D z>+TWv@`DSn;t4W1?9MoI#RGZ|!Z)iNYK~9goKt12QsrwKEf0DXPk!o^VrAmc6cRIx H9gq4SD9pK2 diff --git a/handler/__pycache__/location.cpython-36.pyc b/handler/__pycache__/location.cpython-36.pyc index b96642fa4bdcdc9d68edf13526ceed7a16b4778b..1b73a5bdaddca490a2a3c12b4de687b2235e788d 100644 GIT binary patch literal 4120 zcmb_fU2hy$8J;s=JG0(nM|tq-LJiJY)Dc5p=|imQ9gp7|5q5UaONo$mSc>{s;5@8oL13u zx~yxSQ89C7C6P;1tejOz=902q_fokO#v9&1C7nylHq*;g26KbG{-NBElPV88TRJSa z)iKN4I!bQD87Xh)i4NW+OIBP;#-&tT8i-5jxRjyNw-r9fht4Z}$Vqmz+$h(NE7{>S zoJPsAaHufj*StpH)Dz(6^Rr9m8YSAr)s>?&YAe=&|2hF+@ z>XjOI!h~DRH++YOW~oqdFeEv9x=^h;p37%xm;FB#g(LX+hhZEg$GDPHIpgYiC8u$X z>v-zi;3l31PjCxQlP7r!&jcUfX*?~S!RZG>>sW2JKwFz-Sd9MYsp0oc{QNJ#1WK88 zl(v#r1Ffh8`kM@8gDaTNrn6>f${P`3NH|6h4GRbjK?=LjuUgw5#wHOUkB>V(8}lCsvG3}RGz%7qGs|GA8=WR9al~&C1u_~e}bpm`b}j)CD^rf@wao| zY3oOoSB}h^ZBv|gmH9;5{DIj{aCTUMRi({HJ1Fgtw8OAQ*=kGZ|1dFk{sg^mOWWXE ze~Gn^%e}NU?0j4FF6!kY{a)#!?bBiy=NEJv?%WPVX*~}gIJ1Erfov?s*qF=52$N$3 z$uUBtT?BCLz9;Onryb$+rcJemYle1>p6VS_kjn? zIX4U67HgqCix;~81o~RL{(GKB5Vg-1d|M3AY0_jeWCmf@NRqOu*o8-!s5rh~C^@a| zcC{AR#aaW~bgQW{%QmW3J(dW|(~b+^kclmxP*ED}{z5L`?{ST4-=* zrcnybLcQ)(dDarRL}mR_Lk$!UbvkEg6+AC5OSj3^edg!3XwH`f;veX(r zAn5@r@Jyc`0o4YhT6U=M4xF7zCSR%nRnN`R<@?>MmsfuM`;|Z3>%Q}o?&lY}w|=+! z@!jPcZxSy3K)BV?@{NzXmp<*j`|iG#4?n!W_*(ZuXXWmD50-v0Ikk5C+S;v89xPot zIJLaExP0--{l$+^dunRs-rFm8u19@eo$6lrLsgq-;x>v4sUt3ze)al+t`^AZ|$)_JIy`Jsf{xNEkV-sT&sNTQ#tJPZ{M4RdU z`S$(AH;7PfHNe)RlhNQQ7qLL@b%r!v$c-+4a%bhY*Rck%FPhQ)%jey<-soQb`SMRc zTE2K~^|L!v_~2G|>55z?>X8dYeV83FJDMNe#0y7bqN2Hb_4e}Oduu;>`-P*JxOVTx z>Yewoxo0LOCgG1m!U-CpdI-f$JX;67R1!(W(CX_$>&rg)ex~3x9N!LV>$(v!Z=Lnx zabQ%ERq|aB4?rs-B|;uNO+lDP{50LF?}$L`p($S?^8^_pCI~N?_!VlP$gqK4dcEcc z&!A04FvU>8q=;F>vowBDt(A!xMKfYb(fTo^&Y;3sM5rz%t+;_b*-{VMf};2unbtt1aE^wMcs^u%T8~R-s>NtVuW*EHO3Lb^cMSVdlas7s~RfS|}9Khn@Rm5s1b=?ld3t+6j+5X25KFei3M3I}Wc{r{nHvA!YrOZ_u@`j>$I z6-nht^LVnKJ|NVl7LYddQUnCyd9AI9B|flWL>eP>IYQ%^Hf!r0jnW3nJ|pcznUV~d zkYL3v3u-@PLr=#dcwA)yxwK3;Oe7TB5Z1R#MWuB{`-&<<{Eq2I1;ur;3Z(Li7>8*+ z(E}6d=_WWu(cR@!581OV9nZZF*IV;gj1=VaqO05KT5VE#ZE+N6iMZ}&o;YBi`+!i4HMXdbkioW zHlw{&F{URDl=uw7KO_-@QXpDGu{cDdr?W}=E~w&5DW4Bh`8+~q!=rLKpPy?Kyr@Ue z7mV0X<^UN|A#sQdeLQUdh};vUW@0N01s0!@Op95DwbL50GS&{+lifitD>e`!@iIZV zS7;RJLs1YYqLeWs8}h>OgJQ!IBwoTKlORJMCt(6}CsSxfpNY|@ zlUC<5VG>Gx3=^Q;Q?vv{!Z7o)gY4B0zDHlALTsb9bb)jF1Zz|rs5BkrQD+RT!_jqp bo%ZkBFm%nx;*f5S0s2P}&L!bmE7ogoL6KkcU>MRF=s&!Pn%H ztbM3g`G~~z4N<9>2P7Img5td&T6kAV%&0|rh|9B8c>aAD#BYt2F#CUL$1Q!tJ598{o+^F^q^49@c)x0tBU zKKi$}Y3%t2K?s@jRp4hb?i~eLA?$eFD1en)*z=kg`>DHfLSCx+e^Dc|jDnOrgvoPzhvNc02960Fc~-xn0=&|r7Q4;%SYJa20}6@wmYoV>A`$Az zy+$H#vO72WGLdRKWPLr6+cMF?Y%r9?Tw1v-q14)iM5k{*(~q}r(IIxCf%6#SZRH72 zba039^Aze6A?CZqaxBZu`>!K}!A`sw!rG9X3}@$_fGgVqEI(8dC-H8 z(`WL!W~fTKuCMwpU?ku&Z7+x~q7uD?f^o?OcSo<}Wwb3ElF#F8a95PMT1CGx#zY;q z`w-*LQR%&({%mb{#6AbvKy=$0=!iGsIl@~a-th=;9pOYk!OZb4KoP8At+!cBR%vL} z?WVFZx^hUkEUlX#PEMnq6?d@oIPgMH3+Wf;l22`_ULkR=Qh9V3#T&R0QQ-^=m7_v! zEOc13TF0GnaddCT#l>h)1I6j(;wJB;cZ*N>Lh4#8n{;Ak9QgMriK}F2Xq-DMO7 zI3jWjr^1f5uw)8E}o x%@+vfT7GTK#=#+U_k%a-0!A;RpeCN>rmzt^Q&@jmIjmI<+}e+X(D?*02^2YGynhq diff --git a/log/__pycache__/mylog.cpython-36.pyc b/log/__pycache__/mylog.cpython-36.pyc index 7e29cae17a8d747b1c44e3f40546c8bc5861ae7a..e1170e065c24dced86a79cf61c9269e95e3bdcb1 100644 GIT binary patch delta 16 Xcmcb}dXbggn3tDpy{GO*_ESs%D76H% delta 16 Xcmcb}dXbggn3tEUV3O)a_ESs%D2fEO diff --git a/myredis/__pycache__/__init__.cpython-36.pyc b/myredis/__pycache__/__init__.cpython-36.pyc index 4d7684c0317bc44758930a898fe3543833911644..7c3c5b52235071a7d54da3bf407d67f2ff9b4b34 100644 GIT binary patch delta 13 Ucmb=bVmIdHk delta 13 Ucmb=bVmIdH<+}DnX(D?u02`SEIsgCw diff --git a/myredis/__pycache__/myredis.cpython-36.pyc b/myredis/__pycache__/myredis.cpython-36.pyc index 5315049e3d73df930b9c97cd8e3304681bba8270..2ff9c186f1df61f67ca41bf4db084d24cf44dcfa 100644 GIT binary patch delta 176 zcmaFP{D)cDn3tDJzDhUtDcA>u3p9{-c+_IwiKpd22JjX6TDT}3KENp%TsPKr6h%DvKFxd4Jcv*61O?s_*EK%I4%vn6C+$o&B zj8VL)Y*B0}Ou-DATob2x3o)f6g=n%Au>!Ref%F!!PiAG*V!SokfH6}diZ?kww;(aE pGQKD^C9`-XLlHkn3IF6Zj8-B7Kqe0(2M`J{aWM%n@-gu+0szIS9+v0P3XZ-ARayYW)o>*Sr~?$*|)#u7SrfSj3nMK$teUPo?!jL?+8gBxXctcp(xdNVw%bHi}6mVmzOU z5KZVs>w5d5lvMPS4#c+!N#g9%R&ub6w@-f@Se_x640XiAo9`x@g5F;ipZ|02P8k;yd?M*ALr zmXF+4G>?>U7Oh>&eP>sEXLQDb9>m(Dw>nbV(|vxAzQG$es=N#9s-`aK=IPyd1kLO8 YaTF=q9npPJsOYXJ)FOWAe$O@j0s!xc4gdfE delta 761 zcmZ|NK~K~`6ae6P)9G|NJ6n*&O3WJeAjCa@sPRa=BgTWq#e)Z-kn8|m={8ZwkWE}q zdUHrT`4=!k;>nxFUtnUw$zS2wH{I^8gqSAn^mRJ(z4zwN?3;$XQ?1Gu@8_P?E`652 z*!>%ZXixjb?*kAVa~<>vkX-0635*{T7jKbt2{2mDkmZa@B8D?^m4p^V?ew0%3Kcom zZM4(wW|lYXTRv~U@>}zKqqDo)&a-Jk$Qf&=Tb(nJb#`{vpKokumob>dc(b+ONu;QR zDat`Ygirf2XsujD8ffa6hrA#&hd2krGzu7|knj;q4AXcGPf1GG?2I^q$M%yS+i&7v zvgvkqrqW;^ge$X;@V)Ce1ZHUDF`%Gm1S8RxaJdkn$#^JYD5BcCAfmcZ=Dy~MXS_i% z^B`e^@ldoZH!nI)U9sD0ap9Fq@w!V9o6hi}Sm>xsa+(%}AE*3X{eUC;uKF>EMNLe}`svN+1JoDs Yccp}zjZG3%;K318vZzOV`+Fk(3sg3WcK`qY From aa3610e716edf3657b9de24dead809263dc3d736 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:36:12 +0800 Subject: [PATCH 15/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 99dd235..2876ec9 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -149,10 +149,11 @@ class DispatchHandler(tornado.web.RequestHandler): def _selfGetAdList(self): try: + pdb.set_trace() input = json.loads(self.get_query_argument('body')) gameid = input['gameid'] - channelid=input['channelid'] - area=input.get('locationid',0) + channelid=input.get('channelid',None) or 6001 + area=input.get('area',0) locationid = input.get('locationid',0) except Exception as e: result = {'errcode': 2, "errmsg": f"get args failed,{str(e)}"} From e4188e55ada3e9b0df360066941562c3c2ba4c36 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 15:50:16 +0800 Subject: [PATCH 16/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 2876ec9..bc9371f 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -19,7 +19,7 @@ import pdb define_logger("/data/logs/ad_interface_tornado.log") log = logging.getLogger(__name__) -limit = 3 +limit = 10 def send_cache_data(): @@ -158,12 +158,23 @@ class DispatchHandler(tornado.web.RequestHandler): except Exception as e: result = {'errcode': 2, "errmsg": f"get args failed,{str(e)}"} log.error(result) - self.write_error(2) - return False - if gameid and channelid and locationid: + return self.write_error(2) + if gameid and locationid: key = f"ad::{gameid}::{channelid}::*::{locationid}" - pdb.set_trace() - ids = my_redis.smembers(key) + elif gameid and area: + key = f"ad::{gameid}::{channelid}::{area}*" + else: + pass + keys = my_redis.keys(key) + ids = [] + for item in keys: + one_key = my_redis.smembers(item) + try: + for key in one_key: + ids.append(key) + except Exception: + log.error(f"get redis data failed!", exc_info=True) + return self.write({'errcode': 2, "errmsg": f"get redis data failed!"}) info = [] if not ids: result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} @@ -188,10 +199,10 @@ class DispatchHandler(tornado.web.RequestHandler): result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} except Exception as e: result = {'errcode': 1, "errmsg": e} - self.write(result) + return self.write(result) else: result = {'errcode': 2, "errmsg": f"get args failed!"} - self.write(result) + return self.write(result) def make_app(): From 804f2813ac8780205ebd9eec21f2f68fe096053a Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 16:36:00 +0800 Subject: [PATCH 17/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=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 | 2 +- ad_interface_tornado.py | 23 +++++++++++++---------- handler/location.py | 5 ++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.MD b/README.MD index 7b3c202..6deedb1 100644 --- a/README.MD +++ b/README.MD @@ -246,7 +246,7 @@ http://154.8.214.202:5015/interface/location ##### 请求示范 -http://154.8.214.202:5015/interface/location?gameid=1003&area=1,1,.1&type=1&mode=2 +http://154.8.214.202:5015/interface/location?gameid=1003&area=1,1,1&type=1&mode=2 ##### 请求参数说明 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index bc9371f..aa58296 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -160,36 +160,39 @@ class DispatchHandler(tornado.web.RequestHandler): log.error(result) return self.write_error(2) if gameid and locationid: - key = f"ad::{gameid}::{channelid}::*::{locationid}" + key_word = f"ad::{gameid}::{channelid}::*::{locationid}" elif gameid and area: - key = f"ad::{gameid}::{channelid}::{area}*" + key_word = f"ad::{gameid}::{channelid}::{area}*" else: pass - keys = my_redis.keys(key) + ad_keys = my_redis.keys(key_word) ids = [] - for item in keys: - one_key = my_redis.smembers(item) + for ad_key in ad_keys: + adlists = my_redis.smembers(ad_key) try: - for key in one_key: + for key in adlists: ids.append(key) except Exception: log.error(f"get redis data failed!", exc_info=True) return self.write({'errcode': 2, "errmsg": f"get redis data failed!"}) + dist_ids = list(set(ids)) info = [] - if not ids: + if not dist_ids: result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} else: try: # 如果取得的记录条数大于预设,扔掉多余的记录,当前采用的是随机选择,以后可能需要添加加权选择 id_list = [] - if limit < len(ids): + if limit < len(dist_ids): nums = limit else: - nums = len(ids) + nums = len(dist_ids) for i in range(nums): while 1: - new = my_redis.srandmember(key) + # new = my_redis.srandmember(key) + import random + new = random.choice(dist_ids) if new not in id_list: id_list.append(new) break diff --git a/handler/location.py b/handler/location.py index b21bb62..51ca5da 100644 --- a/handler/location.py +++ b/handler/location.py @@ -64,7 +64,10 @@ class Location(Resource): location['gameid'] = self.args['gameid'] location['channelid'] = self.args['channelid'] or 6001 location['id'] = self.create_id() - self.mydb.insert("location", location) + if location['area'] and location['type'] and location['mode'] and location['gameid'] : + self.mydb.insert("location", location) + 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}) From c86de9c326d68aabc0f293ff91d3ff38d7c48c4c Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 16:50:10 +0800 Subject: [PATCH 18/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 59 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index aa58296..be4543f 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -149,7 +149,6 @@ class DispatchHandler(tornado.web.RequestHandler): def _selfGetAdList(self): try: - pdb.set_trace() input = json.loads(self.get_query_argument('body')) gameid = input['gameid'] channelid=input.get('channelid',None) or 6001 @@ -175,37 +174,35 @@ class DispatchHandler(tornado.web.RequestHandler): except Exception: log.error(f"get redis data failed!", exc_info=True) return self.write({'errcode': 2, "errmsg": f"get redis data failed!"}) - dist_ids = list(set(ids)) - info = [] - if not dist_ids: - result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} - else: - try: - # 如果取得的记录条数大于预设,扔掉多余的记录,当前采用的是随机选择,以后可能需要添加加权选择 - id_list = [] - if limit < len(dist_ids): - nums = limit - else: - nums = len(dist_ids) - - for i in range(nums): - while 1: - # new = my_redis.srandmember(key) - import random - new = random.choice(dist_ids) - if new not in id_list: - id_list.append(new) - break - for id in id_list: - temp = my_redis.hgetall(f"ad::{id}::info") - info.append(temp) - result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} - except Exception as e: - result = {'errcode': 1, "errmsg": e} - return self.write(result) + dist_ids = list(set(ids)) + info = [] + if not dist_ids: + result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} else: - result = {'errcode': 2, "errmsg": f"get args failed!"} - return self.write(result) + try: + # 如果取得的记录条数大于预设,扔掉多余的记录,当前采用的是随机选择,以后可能需要添加加权选择 + id_list = [] + if limit < len(dist_ids): + nums = limit + else: + nums = len(dist_ids) + + for i in range(nums): + while 1: + # new = my_redis.srandmember(key) + import random + new = random.choice(dist_ids) + if new not in id_list: + id_list.append(new) + break + for id in id_list: + temp = my_redis.hgetall(f"ad::{id}::info") + info.append(temp) + result = {'errcode': 0, "errmsg": '', "message": {"totoal": len(info), "result": info}} + except Exception as e: + result = {'errcode': 1, "errmsg": e} + return self.write(result) + def make_app(): From bb0ad4ee948ea58fc660cb9a1ee8394aae741327 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 16:55:04 +0800 Subject: [PATCH 19/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index be4543f..058fbb6 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -90,7 +90,7 @@ def send_cache_data(): if not my_redis.exists(f"ad::{line['id']}::info"): # remove some filed from adinfo - remove_list = ('ad_num', 'companyid', 'gameid') + remove_list = ('ad_num', 'gameid') for item in remove_list: line.pop(item) my_redis.hmset(f"ad::{line['id']}::info", line) From 769be2e4175c47c8bb0f1e3bf6bcd03af95033fb Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 17:03:01 +0800 Subject: [PATCH 20/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_Readme.md | 1 + handler/company.py | 2 +- handler/location.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ad_Readme.md b/ad_Readme.md index 40b362d..db2677d 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -11,6 +11,7 @@ http://ad.kingsome.cn/webapp/index.php ##### 请求示范 http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} +http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:6001","channelid":6001,"area":1} ##### 请求参数说明 diff --git a/handler/company.py b/handler/company.py index 96aaa6e..e11af79 100644 --- a/handler/company.py +++ b/handler/company.py @@ -66,7 +66,7 @@ class Company(Resource): id = self.args['id'] try: del_sql = f'delete from company where id={id};' - self.mydb.query(del_sql) + self.mydb.change(del_sql) except Exception: log.error(f"remove {id} failed!", exc_info=True) return jsonify({'code': 500}) diff --git a/handler/location.py b/handler/location.py index 51ca5da..205770f 100644 --- a/handler/location.py +++ b/handler/location.py @@ -116,7 +116,7 @@ class Location(Resource): return jsonify({'code': 500, 'message': 'id not found'}) try: del_sql = f'delete from location where id={id};' - self.mydb.query(del_sql) + self.mydb.change(del_sql) except Exception: log.error(f"location remove {id} failed!", exc_info=True) return jsonify({'code': 500}) From 37e5a2fbe3246ed64636caa28a6f36460634740b Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 17:09:39 +0800 Subject: [PATCH 21/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 3 ++- handler/company.py | 2 +- handler/location.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index 3b56a25..5180276 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -173,7 +173,8 @@ class Ad(Resource): id = self.args['id'] or None if not id: return jsonify({'code': 404, 'message': f'{id} not found!'}) - del_sql = f"delete from ad where id={id};" + #del_sql = f"delete from ad 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!'}) diff --git a/handler/company.py b/handler/company.py index e11af79..302d65a 100644 --- a/handler/company.py +++ b/handler/company.py @@ -65,7 +65,7 @@ class Company(Resource): def delete(self): id = self.args['id'] try: - del_sql = f'delete from company where id={id};' + del_sql = f'update ad set in_used=0 where id={id};' self.mydb.change(del_sql) except Exception: log.error(f"remove {id} failed!", exc_info=True) diff --git a/handler/location.py b/handler/location.py index 205770f..53a3fa2 100644 --- a/handler/location.py +++ b/handler/location.py @@ -115,7 +115,7 @@ class Location(Resource): if not id: return jsonify({'code': 500, 'message': 'id not found'}) try: - del_sql = f'delete from location where id={id};' + del_sql = f'update location set in_used=0 where id={id};' self.mydb.change(del_sql) except Exception: log.error(f"location remove {id} failed!", exc_info=True) From 0f808baf02dd9fb6ae60e6d554ebc7663394456e Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 17:12:37 +0800 Subject: [PATCH 22/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index 5180276..bb92861 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -56,16 +56,18 @@ class Ad(Resource): 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," \ - f"status,companyid,locationid,gameid,channelid,jump_status from ad where companyid={companyid};" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 and " \ + f"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," \ - f"status,companyid,locationid,gameid,channelid,jump_status from ad where status={status};" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 and \ + status={status};" else: 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,channelid,jump_status from ad ;" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 ;" else: 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,channelid,jump_status from ad where id={id};" + f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 and id={id};" data = self.mydb.query(sel_sql) log.info(f"sql={sel_sql},data={data}") if data: From dee7d7892d62bbb16a2bb8938208dd5519d65ab8 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 25 Jul 2019 17:16:28 +0800 Subject: [PATCH 23/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 2 +- ad_Readme.md | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.MD b/README.MD index 6deedb1..c689b4e 100644 --- a/README.MD +++ b/README.MD @@ -320,7 +320,7 @@ http://154.8.214.202:5015/interface/location ##### 请求示范 -http://154.8.214.202:5015/interface/location?id=1002 +http://154.8.214.202:5015/interface/location?id=1015 ##### 请求参数说明 diff --git a/ad_Readme.md b/ad_Readme.md index db2677d..84f12f5 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -42,18 +42,26 @@ http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:60 "errcode": 0, "errmsg": "", "message": { - "totoal": 3, + "totoal": 1, "result": [ { - "ad_body": "11", - "ad_image": "https://resource.kingsome.cn//ad/f7daf1a2-a864-11e9-bf18-525400ddcafb_500甜心icon(1)(1).png", + "ad_body": "33", + "ad_image": "https://resource.kingsome.cn//ad/1d7bb7a2-a865-11e9-8df4-525400ddcafb_banner12(1).png", "ad_sort": "0", - "ad_title": "aa", - "id": "1009", - "jump_param": "aas1", + "ad_title": "333", + "area": "1,0,0", + "channelid": "6001", + "companyid": "1002", + "id": "1014", + "jump_param": "fdfd", "jump_status": "0", - "name": "1122" - }, + "locationid": "1001", + "mode": "0", + "name": "33", + "type": "1" + } + ] + } } #### 2、广告播放上报 From 2517ed96664da4f0ba73da66aa4eab17ec36d200 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 26 Jul 2019 13:34:04 +0800 Subject: [PATCH 24/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index bb92861..cefd3e8 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -55,19 +55,23 @@ 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,jump_param,ad_sort," \ - f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 and " \ - f"companyid={companyid};" + sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ + f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ + f"b.area,b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and " \ + f"a.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," \ - f"status,companyid,locationid,gameid,channelid,jump_status from ad where in_used=1 and \ - status={status};" + sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ + f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ + f"b.area,b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and \ + a.status={status};" else: - 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,channelid,jump_status from ad where in_used=1 ;" + sel_sql = f"SELECT a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ + f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ + f"b.area,b.type,b.mode FROM ad a,location b WHERE a.locationid=b.id AND a.in_used=1 ;" else: - 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,channelid,jump_status from ad where in_used=1 and id={id};" + sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ + f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status,b.area," \ + f"b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and a.id={id};" data = self.mydb.query(sel_sql) log.info(f"sql={sel_sql},data={data}") if data: From dddf1e40b63d95ca2699b25ace4613221f6afb33 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 26 Jul 2019 13:35:19 +0800 Subject: [PATCH 25/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index cefd3e8..0847a4a 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -81,8 +81,9 @@ class Ad(Resource): 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['jump_param'], ad_info[ - 'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info[ - 'gameid'],ad_info['channelid'],ad_info['jump_status'] = line + 'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info['gameid'], \ + ad_info['channelid'], ad_info['jump_status'], ad_info['area'], ad_info['type'], ad_info[ + 'mode'] = line all.append(ad_info) return jsonify({'code': 200, 'message': all}) except Exception: From 68d6e1e326513ecd3be94f4da3e897d4d8fa20e8 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 2 Aug 2019 14:40:13 +0800 Subject: [PATCH 26/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 2 -- ad_interface_tornado.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.MD b/README.MD index c689b4e..3e4f496 100644 --- a/README.MD +++ b/README.MD @@ -479,8 +479,6 @@ http://154.8.214.202:5015/interface/ad ##### 请求示范 - - http://154.8.214.202:5015/interface/ad?id=1002 http://154.8.214.202:5015/interface/ad?companyid=0 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 058fbb6..e0d6453 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -30,7 +30,7 @@ def send_cache_data(): # 添加无天数限定的记录 get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \ f"a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where \ - a.locationid=b.id AND begin_time='{BEGIN}' or end_time='{END}'""" + a.locationid=b.id AND a.status=1 AND a.in_used=1 AND begin_time='{BEGIN}' or end_time='{END}'""" full_data = mydb.query(get_full_data) if full_data: @@ -49,7 +49,7 @@ def send_cache_data(): # 添加有天数限定的记录 get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,\ a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a ,location b \ - where'{now}'>a.begin_time and '{now}'a.begin_time and '{now}' Date: Fri, 2 Aug 2019 14:45:39 +0800 Subject: [PATCH 27/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index e0d6453..bcca4a8 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,9 +28,7 @@ def send_cache_data(): now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] # 添加无天数限定的记录 - get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \ - f"a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where \ - a.locationid=b.id AND a.status=1 AND a.in_used=1 AND begin_time='{BEGIN}' or end_time='{END}'""" + get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where a.locationid=b.id AND a.status=1 AND a.in_used=1 AND begin_time='{BEGIN}' or end_time='{END}'""" full_data = mydb.query(get_full_data) if full_data: @@ -47,9 +45,7 @@ def send_cache_data(): log.error("split data failed", exc_info=True) # 添加有天数限定的记录 - get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,\ - a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a ,location b \ - where'{now}'>a.begin_time and '{now}'a.begin_time and '{now}' Date: Fri, 2 Aug 2019 15:44:58 +0800 Subject: [PATCH 28/47] a --- ad_interface_tornado.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index bcca4a8..7f8a964 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,7 +28,7 @@ def send_cache_data(): now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] # 添加无天数限定的记录 - get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where a.locationid=b.id AND a.status=1 AND a.in_used=1 AND begin_time='{BEGIN}' or end_time='{END}'""" + get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,a.locationid from ad a,location b where a.locationid=b.id AND a.status=1 AND a.in_used=1 AND a.begin_time='{BEGIN}' or a.end_time='{END}'""" full_data = mydb.query(get_full_data) if full_data: @@ -45,7 +45,7 @@ def send_cache_data(): log.error("split data failed", exc_info=True) # 添加有天数限定的记录 - get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a ,location b where'{now}'>a.begin_time and '{now}'a.begin_time and '{now}' Date: Fri, 2 Aug 2019 17:06:33 +0800 Subject: [PATCH 29/47] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_Readme.md | 3 ++ ad_interface_tornado.py | 96 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/ad_Readme.md b/ad_Readme.md index 84f12f5..3bcb318 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -35,6 +35,9 @@ http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:60 | name | string | 是 | 广告名称 | | jump_status | int | 是 | 跳转状态,1=跳转,0=不跳 | | jump_param | string | 是 | 跳转参数 | +| area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 | +| type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | +| mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | ##### 返回示例 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 7f8a964..4370448 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,7 +28,52 @@ def send_cache_data(): now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] # 添加无天数限定的记录 - get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,a.locationid from ad a,location b where a.locationid=b.id AND a.status=1 AND a.in_used=1 AND a.begin_time='{BEGIN}' or a.end_time='{END}'""" + get_full_data = f"""SELECT + a.id, + a.name, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.companyid, + a.gameid, + a.channelid, + a.jump_status, + b.area, + b.type, + b.mode, + a.locationid + FROM + (SELECT + id, + name, + ad_num, + ad_title, + ad_body, + ad_image, + jump_param, + ad_sort, + companyid, + gameid, + channelid, + jump_status, + locationid + FROM + ad + WHERE + status=1 + AND in_used=1 AND (begin_time='{BEGIN}' OR end_time='{END}')) a , + (SELECT + id, + area, + type, + mode + FROM + location) b + WHERE + a.locationid=b.id""" full_data = mydb.query(get_full_data) if full_data: @@ -45,7 +90,54 @@ def send_cache_data(): log.error("split data failed", exc_info=True) # 添加有天数限定的记录 - get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,a.locationid from ad a ,location b where'{now}'>a.begin_time and '{now}' begin_time + and '{now}' Date: Mon, 5 Aug 2019 10:32:56 +0800 Subject: [PATCH 30/47] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=9F=E5=90=8Dad?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 86 +++++++++++++++++++--------------------------------- ad_Readme.md | 10 +++--- server.py | 2 +- 3 files changed, 37 insertions(+), 61 deletions(-) diff --git a/README.MD b/README.MD index 3e4f496..bad804d 100644 --- a/README.MD +++ b/README.MD @@ -44,31 +44,21 @@ http://154.8.214.202:5015/interface/company?status=0 | companykey | string | 是 | 用于API认证 | ##### 返回示例 - { - "code": 200, - "message": [ - { - "appid": "zpoHY37u", - "appkey": "undefined", - "contact": "miles", - "id": "1006", - "name": "kingsome", - "status": 0, - "tel": "17771" - }, - { - "appid": "5bOaA82t", - "appkey": "undefined", - "contact": "miles", - "id": "1007", - "name": "kingsome", - "status": 0, - "tel": "17771" - } - ] + "code": 200, + "message": [ + { + "appid": "BKadJbmZ", + "appkey": "undefined", + "contact": "pt", + "id": "1001", + "name": "kings", + "status": 0, + "tel": "1234", + "user": "None" + } + ] } - #### 2、新增公司信息 ##### 接口地址 @@ -207,33 +197,19 @@ http://154.8.214.202:5015/interface/location?gameid=1004 | message | json | 是 | 所有位置信息 | ##### 返回示例 - { - "code": 200, - "message": [ - - { - -​ "area": "1,1,.1", - -​ "channelid": 6001, - -​ "gameid": 1003, - -​ "id": 1010, - -​ "mode": 2, - -​ "type": 1 - -​ } - + { + "area": "1,8,15", + "channelid": 6001, + "gameid": 1004, + "id": 1007, + "mode": 1, + "type": 2 + } ] - } - #### 6、添加位置服务信息 ##### 接口地址 @@ -346,7 +322,7 @@ http://154.8.214.202:5015/interface/location?id=1015 ##### 接口地址 -http://154.8.214.202:5015/interface/ad +http://154.8.214.202:5015/interface/prometion ##### 返回格式:json @@ -354,7 +330,7 @@ http://154.8.214.202:5015/interface/ad ##### 请求示范 -http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 +http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 ##### 请求参数说明 @@ -391,7 +367,7 @@ http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_titl ##### 接口地址 -http://154.8.214.202:5015/interface/ad +http://154.8.214.202:5015/interface/prometion ##### 返回格式:json @@ -399,7 +375,7 @@ http://154.8.214.202:5015/interface/ad ##### 请求示范 -http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 +http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 ##### 请求参数说明 @@ -439,7 +415,7 @@ http://154.8.214.202:5015/interface/ad?name=abc&gameid=1003&locationid=1&ad_titl ##### 接口地址 -http://154.8.214.202:5015/interface/ad +http://154.8.214.202:5015/interface/prometion ##### 返回格式:json @@ -447,7 +423,7 @@ http://154.8.214.202:5015/interface/ad ##### 请求示范 -http://154.8.214.202:5015/interface/ad +http://154.8.214.202:5015/interface/prometion ##### 请求参数说明 @@ -471,7 +447,7 @@ http://154.8.214.202:5015/interface/ad ##### 接口地址 -http://154.8.214.202:5015/interface/ad +http://154.8.214.202:5015/interface/prometion ##### 返回格式:json @@ -479,11 +455,11 @@ http://154.8.214.202:5015/interface/ad ##### 请求示范 -http://154.8.214.202:5015/interface/ad?id=1002 +http://154.8.214.202:5015/interface/prometion?id=1002 -http://154.8.214.202:5015/interface/ad?companyid=0 +http://154.8.214.202:5015/interface/prometion?companyid=0 -http://154.8.214.202:5015/interface/ad?status=0 +http://154.8.214.202:5015/interface/prometion?status=0 ##### 请求参数说明 diff --git a/ad_Readme.md b/ad_Readme.md index 3bcb318..c93a7f8 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -2,7 +2,7 @@ ##### 接口地址 -http://ad.kingsome.cn/webapp/index.php +http://prometion.kingsome.cn/webapp/index.php ##### 返回格式:json @@ -10,8 +10,8 @@ http://ad.kingsome.cn/webapp/index.php ##### 请求示范 -http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} -http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:6001","channelid":6001,"area":1} +http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} +http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:6001","channelid":6001,"area":1} ##### 请求参数说明 @@ -71,7 +71,7 @@ http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:60 ##### 接口地址 -http://ad.kingsome.cn/webapp/index.php +http://prometion.kingsome.cn/webapp/index.php ##### 返回格式:json @@ -79,7 +79,7 @@ http://ad.kingsome.cn/webapp/index.php ##### 请求示范 -http://ad.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009 +http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009 ##### 请求参数说明 diff --git a/server.py b/server.py index d463000..0578bfa 100644 --- a/server.py +++ b/server.py @@ -21,7 +21,7 @@ api = Api(app) api.add_resource(Company, '/interface/company') api.add_resource(Location, '/interface/location') -api.add_resource(Ad, '/interface/ad') +api.add_resource(Ad, '/interface/prometion') api.add_resource(Cos_sdk, '/interface/cos_upload') From 9a306639402c2133a632574a117f02ad87b8a967 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 10:40:33 +0800 Subject: [PATCH 31/47] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 18 +++++++++--------- server.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.MD b/README.MD index bad804d..a3c0c42 100644 --- a/README.MD +++ b/README.MD @@ -330,7 +330,7 @@ http://154.8.214.202:5015/interface/prometion ##### 请求示范 -http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 +http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 ##### 请求参数说明 @@ -367,7 +367,7 @@ http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1& ##### 接口地址 -http://154.8.214.202:5015/interface/prometion +http://154.8.214.202:5015/interface/promotion ##### 返回格式:json @@ -375,7 +375,7 @@ http://154.8.214.202:5015/interface/prometion ##### 请求示范 -http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 +http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&begin_time=2019-06-01&end_time=2019-12-01&ad_num=300&ad_sort=1&status=1&id=1001&companyid=2 ##### 请求参数说明 @@ -415,7 +415,7 @@ http://154.8.214.202:5015/interface/prometion?name=abc&gameid=1003&locationid=1& ##### 接口地址 -http://154.8.214.202:5015/interface/prometion +http://154.8.214.202:5015/interface/promotion ##### 返回格式:json @@ -423,7 +423,7 @@ http://154.8.214.202:5015/interface/prometion ##### 请求示范 -http://154.8.214.202:5015/interface/prometion +http://154.8.214.202:5015/interface/promotion ##### 请求参数说明 @@ -447,7 +447,7 @@ http://154.8.214.202:5015/interface/prometion ##### 接口地址 -http://154.8.214.202:5015/interface/prometion +http://154.8.214.202:5015/interface/promotion ##### 返回格式:json @@ -455,11 +455,11 @@ http://154.8.214.202:5015/interface/prometion ##### 请求示范 -http://154.8.214.202:5015/interface/prometion?id=1002 +http://154.8.214.202:5015/interface/promotion?id=1002 -http://154.8.214.202:5015/interface/prometion?companyid=0 +http://154.8.214.202:5015/interface/promotion?companyid=0 -http://154.8.214.202:5015/interface/prometion?status=0 +http://154.8.214.202:5015/interface/promotion?status=0 ##### 请求参数说明 diff --git a/server.py b/server.py index 0578bfa..f145ccb 100644 --- a/server.py +++ b/server.py @@ -21,7 +21,7 @@ api = Api(app) api.add_resource(Company, '/interface/company') api.add_resource(Location, '/interface/location') -api.add_resource(Ad, '/interface/prometion') +api.add_resource(Ad, '/interface/promotion') api.add_resource(Cos_sdk, '/interface/cos_upload') From cab9dfe56c0f00c68626bda1c16fc163b8b31042 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 11:15:09 +0800 Subject: [PATCH 32/47] fix --- ad_Readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ad_Readme.md b/ad_Readme.md index c93a7f8..91da393 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -2,7 +2,7 @@ ##### 接口地址 -http://prometion.kingsome.cn/webapp/index.php +http://promotion.kingsome.cn/webapp/index.php ##### 返回格式:json @@ -10,8 +10,8 @@ http://prometion.kingsome.cn/webapp/index.php ##### 请求示范 -http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} -http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004:6001","channelid":6001,"area":1} +http://promotion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003","channelid":6001,"locationid":1001} +http://promotion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1004","channelid":6001,"area":1} ##### 请求参数说明 @@ -71,7 +71,7 @@ http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":" ##### 接口地址 -http://prometion.kingsome.cn/webapp/index.php +http://promotion.kingsome.cn/webapp/index.php ##### 返回格式:json @@ -79,7 +79,7 @@ http://prometion.kingsome.cn/webapp/index.php ##### 请求示范 -http://prometion.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009 +http://promotion.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009 ##### 请求参数说明 From f245afa719a7a93383010cc5f3e5402e79d8af53 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 13:40:03 +0800 Subject: [PATCH 33/47] fix --- ad_interface_tornado.py | 126 +++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 4370448..604838c 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -27,67 +27,67 @@ def send_cache_data(): log.info("start update cache !") now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] - # 添加无天数限定的记录 - get_full_data = f"""SELECT - a.id, - a.name, - a.ad_num, - a.ad_title, - a.ad_body, - a.ad_image, - a.jump_param, - a.ad_sort, - a.companyid, - a.gameid, - a.channelid, - a.jump_status, - b.area, - b.type, - b.mode, - a.locationid - FROM - (SELECT - id, - name, - ad_num, - ad_title, - ad_body, - ad_image, - jump_param, - ad_sort, - companyid, - gameid, - channelid, - jump_status, - locationid - FROM - ad - WHERE - status=1 - AND in_used=1 AND (begin_time='{BEGIN}' OR end_time='{END}')) a , - (SELECT - id, - area, - type, - mode - FROM - location) b - WHERE - a.locationid=b.id""" - full_data = mydb.query(get_full_data) - - if full_data: - for line in full_data: - if line: - log.info(f"line was {line}") - item = {} - try: - item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ - 'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line - all.append(item) - except Exception: - log.error("split data failed", exc_info=True) + # # 添加无天数限定的记录 + # get_full_data = f"""SELECT + # a.id, + # a.name, + # a.ad_num, + # a.ad_title, + # a.ad_body, + # a.ad_image, + # a.jump_param, + # a.ad_sort, + # a.companyid, + # a.gameid, + # a.channelid, + # a.jump_status, + # b.area, + # b.type, + # b.mode, + # a.locationid + # FROM + # (SELECT + # id, + # name, + # ad_num, + # ad_title, + # ad_body, + # ad_image, + # jump_param, + # ad_sort, + # companyid, + # gameid, + # channelid, + # jump_status, + # locationid + # FROM + # ad + # WHERE + # status=1 + # AND in_used=1 AND (begin_time='{BEGIN}' OR end_time='{END}')) a , + # (SELECT + # id, + # area, + # type, + # mode + # FROM + # location) b + # WHERE + # a.locationid=b.id""" + # full_data = mydb.query(get_full_data) + # + # if full_data: + # for line in full_data: + # if line: + # log.info(f"line was {line}") + # item = {} + # try: + # item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ + # 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ + # 'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line + # all.append(item) + # except Exception: + # log.error("split data failed", exc_info=True) # 添加有天数限定的记录 get_data_sql = f"""select @@ -142,6 +142,7 @@ def send_cache_data(): data = mydb.query(get_data_sql) if data: for line in data: + if line: item = {} try: @@ -153,9 +154,12 @@ def send_cache_data(): log.error("split data failed", exc_info=True) # 检查ID是否存在播放列表中,以及播放次数是否完毕 if all: + print(f"{data}\n") # log.info(f"get data was {all}!\n") for line in all: + print(f"line={line}") key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}::{line.get('locationid', 0)}" + print(f"key={key}\n") if int(line['ad_num']) > 0: num = my_redis.get(f"ad::{line['id']}::num") if not num: From f7684608910a303bdfccdc57cae06a4f41021601 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 13:43:56 +0800 Subject: [PATCH 34/47] fix --- ad_interface_tornado.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 604838c..7734b47 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -154,12 +154,9 @@ def send_cache_data(): log.error("split data failed", exc_info=True) # 检查ID是否存在播放列表中,以及播放次数是否完毕 if all: - print(f"{data}\n") # log.info(f"get data was {all}!\n") for line in all: - print(f"line={line}") key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}::{line.get('locationid', 0)}" - print(f"key={key}\n") if int(line['ad_num']) > 0: num = my_redis.get(f"ad::{line['id']}::num") if not num: From 465b686187c6dcb38b43186391984bac046d4469 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 14:00:56 +0800 Subject: [PATCH 35/47] fix --- README.MD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.MD b/README.MD index a3c0c42..d214fee 100644 --- a/README.MD +++ b/README.MD @@ -511,3 +511,5 @@ http://154.8.214.202:5015/interface/promotion?status=0 } } +#### ad_channel 获得接口 +http://mp.kingsome.cn/api/open/promotion/get-uid?game_id=8002&platform_id=6001 \ No newline at end of file From a807e052e7466c436947c0977a8c70cc3bbcf56e Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 5 Aug 2019 14:53:46 +0800 Subject: [PATCH 36/47] =?UTF-8?q?=E4=BF=AE=E6=94=B9ad=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 2 +- ad_interface_tornado.py | 25 ++++++++++++++++++++++--- handler/ad.py | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.MD b/README.MD index d214fee..f7b52d6 100644 --- a/README.MD +++ b/README.MD @@ -411,7 +411,7 @@ http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1& "code": 200 } -#### 11、删除广告信息 +#### 11、删除广告信息,实际将status 改为4 ##### 接口地址 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 7734b47..cac448e 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -189,15 +189,34 @@ def send_cache_data(): # 删除过期的数据 log.info("remove expire data from cache!") - expire_sql = f"select id,gameid,locationid from ad where '{now}'>end_time" + + expire_sql = f"""select + a.id,a.gameid,a.channelid,a.locationid,a.status,b.area + from + (select + id,gameid,channelid,locationid,status + from + ad + where + '{now}'> end_time + or status in (3,4) ) a , + (select + id, + area + from + location) b + where + a.locationid=b.id""" remove_data = mydb.query(expire_sql) if remove_data: for line in remove_data: try: - id, gameid, locationid = line - key = f"{gameid}:{locationid}" + id, gameid, channelid, locationid, _, area = line + key = f"ad::{gameid}::{channelid}::{area.split(',')[0].strip()}::{locationid}" + # key = f"{gameid}:{locationid}" if my_redis.sismember(key, id): my_redis.srem(key, id) + my_redis.expire(f"ad::{id}::info", 1) log.info(f"remove {id} from {key} success!") except Exception: log.error("拆解过期数据出错!", exc_info=True) diff --git a/handler/ad.py b/handler/ad.py index 0847a4a..215dfaa 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -181,7 +181,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 in_used=0 where id={id};" + del_sql = f"update ad set status=4 where id={id};" try: self.mydb.change(del_sql) return jsonify({'code': 200, 'message': f'remove adid={id} success!'}) From da806b3d51b5477448dbfe1c64679e477b6ddc5f Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 6 Aug 2019 11:54:55 +0800 Subject: [PATCH 37/47] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E7=9A=84=E4=B8=BAlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index cac448e..b2681d8 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -238,15 +238,17 @@ class DispatchHandler(tornado.web.RequestHandler): def _upAdRecording(self): try: adid = self.get_query_argument('adid') + ids = json.loads(adid) except Exception: result = {'errcode': 2, "errmsg": f"get args failed`"} log.error(result, exc_info=True) self.write({'errcode': 1, "errmsg": 'get adid failed!'}) - if adid: - key = f"ad::{adid}::num" - my_redis.incr(key, amount=1) - self.write({'errcode': 0, "errmsg": '', "message": f"{adid} incr success!"}) + for id in ids: + if id: + key = f"ad::{id}::num" + my_redis.incr(key, amount=1) + self.write({'errcode': 0, "errmsg": '', "message": f"{id} incr success!"}) def _selfCheckingHandler(self): From 8cc75e6315c9886dd91e658f4a6ce31648872665 Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 6 Aug 2019 11:58:35 +0800 Subject: [PATCH 38/47] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E7=9A=84=E4=B8=BAlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index b2681d8..9c93c84 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -238,17 +238,19 @@ class DispatchHandler(tornado.web.RequestHandler): def _upAdRecording(self): try: adid = self.get_query_argument('adid') + log.info(f" get adid was {adid}") ids = json.loads(adid) except Exception: result = {'errcode': 2, "errmsg": f"get args failed`"} log.error(result, exc_info=True) self.write({'errcode': 1, "errmsg": 'get adid failed!'}) - for id in ids: - if id: - key = f"ad::{id}::num" - my_redis.incr(key, amount=1) - self.write({'errcode': 0, "errmsg": '', "message": f"{id} incr success!"}) + if ids: + for id in ids: + if id: + key = f"ad::{id}::num" + my_redis.incr(key, amount=1) + self.write({'errcode': 0, "errmsg": '', "message": f"{id} incr success!"}) def _selfCheckingHandler(self): From 78613cb0532ce58748c674e206602ddb7b470c6a Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 6 Aug 2019 12:11:32 +0800 Subject: [PATCH 39/47] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E7=9A=84=E4=B8=BAlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 9c93c84..848a3a8 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -14,6 +14,7 @@ import logging from config import BEGIN, END, ad_list_interface_port from tornado import gen import pdb +from urllib.parse import unquote define_logger("/data/logs/ad_interface_tornado.log") @@ -237,7 +238,7 @@ class DispatchHandler(tornado.web.RequestHandler): def _upAdRecording(self): try: - adid = self.get_query_argument('adid') + adid = unquote(self.get_query_argument('adid'), 'utf-8') log.info(f" get adid was {adid}") ids = json.loads(adid) except Exception: From c39ce464e282171209ff6316d761ddc4c8015f86 Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 6 Aug 2019 13:15:59 +0800 Subject: [PATCH 40/47] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E7=9A=84=E4=B8=BAlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 848a3a8..48c785c 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -251,7 +251,9 @@ class DispatchHandler(tornado.web.RequestHandler): if id: key = f"ad::{id}::num" my_redis.incr(key, amount=1) - self.write({'errcode': 0, "errmsg": '', "message": f"{id} incr success!"}) + self.write({'errcode': 0, "errmsg": '', "message": f"{ids} incr success!"}) + else: + self.write({'errcode': 1, "errmsg": 'get adid failed!'}) def _selfCheckingHandler(self): From 76e6f4b8b8527e2edfd9e230c18c876136d9e6b9 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 11:49:39 +0800 Subject: [PATCH 41/47] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E7=9A=84=E4=B8=BAlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 68 +++++++++++---------- ad_Readme.md | 1 + ad_interface_tornado.py | 67 +-------------------- handler/ad.py | 130 +++++++++++++++++++++++++++++++++++----- 4 files changed, 153 insertions(+), 113 deletions(-) diff --git a/README.MD b/README.MD index f7b52d6..0f21d47 100644 --- a/README.MD +++ b/README.MD @@ -334,22 +334,23 @@ http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1& ##### 请求参数说明 -| 名称 | 类型 | 必填 | 说明 | -| ---------- | -------- | ---- | ------------------------------------------------------- | -| name | string | 是 | 广告名称 | -| gameid | int | 是 | 广告投放的游戏ID | -| channelid | int | 是 | 渠道ID,默认是6001 NEW | -| locationid | int | 是 | 位置ID,通过该ID到localtion表中获得area,type,mode信息 | -| ad_title | string | 是 | 广告标题 | -| ad_body | string | 是 | 广告正文 | -| ad_image | string | 是 | 头像链接 | -| ad_url | string | 是 | 跳转链接 | -| begin_time | datetime | 否 | 开始时间,默认是1999-01-01 | -| end_time | datetime | 否 | 结束时间,默认是3000-01-01 | -| ad_num | int | 否 | 投放次数,默认是0(次数无限) | -| ad_sort | int | 否 | 优先级默认为0 | -| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| companyid | int | 是 | 广告提交公司 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | -------- | ---- | ------------------------------------------------------- | +| name | string | 是 | 广告名称 | +| gameid | int | 是 | 广告投放的游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 NEW | +| locationid | int | 是 | 位置ID,通过该ID到localtion表中获得area,type,mode信息 | +| ad_title | string | 是 | 广告标题 | +| ad_body | string | 是 | 广告正文 | +| ad_image | string | 是 | 头像链接 | +| ad_url | string | 是 | 跳转链接 | +| begin_time | datetime | 否 | 开始时间,默认是1999-01-01 | +| end_time | datetime | 否 | 结束时间,默认是3000-01-01 | +| ad_num | int | 否 | 投放次数,默认是0(次数无限) | +| ad_sort | int | 否 | 优先级默认为0 | +| status | int | 否 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | +| companyid | int | 是 | 广告提交公司 | +| ad_property | json | 是 | 广告属性描述 | ##### 返回参数说明 @@ -381,23 +382,24 @@ http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1& ##### -| 名称 | 类型 | 必填 | 说明 | -| ---------- | -------- | ---- | --------------------------------------------------- | -| id | int | 是 | 广告ID | -| name | string | 是 | 广告名称 | -| gameid | int | 是 | 广告投放的游戏ID | -| channelid | int | 是 | 渠道ID,默认是6001 NEW | -| locationid | int | 是 | 位置ID | -| ad_title | string | 是 | 广告标题 | -| ad_body | string | 是 | 广告正文 | -| ad_image | string | 是 | 头像链接 | -| ad_url | string | 是 | 跳转链接 | -| begin_time | datetime | 是 | 开始时间,默认是1999-01-01 | -| end_time | datetime | 是 | 结束时间,默认是3000-01-01 | -| ad_num | int | 是 | 投放次数,默认是-1(无限) | -| ad_sort | int | 是 | 优先级默认为0 | -| status | int | 是 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | -| companyid | int | 是 | 广告提交公司 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | -------- | ---- | --------------------------------------------------- | +| id | int | 是 | 广告ID | +| name | string | 是 | 广告名称 | +| gameid | int | 是 | 广告投放的游戏ID | +| channelid | int | 是 | 渠道ID,默认是6001 NEW | +| locationid | int | 是 | 位置ID | +| ad_title | string | 是 | 广告标题 | +| ad_body | string | 是 | 广告正文 | +| ad_image | string | 是 | 头像链接 | +| ad_url | string | 是 | 跳转链接 | +| begin_time | datetime | 是 | 开始时间,默认是1999-01-01 | +| end_time | datetime | 是 | 结束时间,默认是3000-01-01 | +| ad_num | int | 是 | 投放次数,默认是-1(无限) | +| ad_sort | int | 是 | 优先级默认为0 | +| status | int | 是 | 默认为0(未审批),1=审批通过,2=审批未通过,3=暂停 | +| companyid | int | 是 | 广告提交公司 | +| ad_property | json | 是 | 广告属性描述 | ##### 返回参数说明 diff --git a/ad_Readme.md b/ad_Readme.md index 91da393..953ac09 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -38,6 +38,7 @@ http://promotion.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":" | area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 | | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | | mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | +| ad_property | string | 是 | 广告属性描述 | ##### 返回示例 diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 48c785c..09ee7de 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,69 +28,7 @@ def send_cache_data(): log.info("start update cache !") now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] - # # 添加无天数限定的记录 - # get_full_data = f"""SELECT - # a.id, - # a.name, - # a.ad_num, - # a.ad_title, - # a.ad_body, - # a.ad_image, - # a.jump_param, - # a.ad_sort, - # a.companyid, - # a.gameid, - # a.channelid, - # a.jump_status, - # b.area, - # b.type, - # b.mode, - # a.locationid - # FROM - # (SELECT - # id, - # name, - # ad_num, - # ad_title, - # ad_body, - # ad_image, - # jump_param, - # ad_sort, - # companyid, - # gameid, - # channelid, - # jump_status, - # locationid - # FROM - # ad - # WHERE - # status=1 - # AND in_used=1 AND (begin_time='{BEGIN}' OR end_time='{END}')) a , - # (SELECT - # id, - # area, - # type, - # mode - # FROM - # location) b - # WHERE - # a.locationid=b.id""" - # full_data = mydb.query(get_full_data) - # - # if full_data: - # for line in full_data: - # if line: - # log.info(f"line was {line}") - # item = {} - # try: - # item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - # 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ - # 'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line - # all.append(item) - # except Exception: - # log.error("split data failed", exc_info=True) - # 添加有天数限定的记录 get_data_sql = f"""select a.id, a.name, @@ -104,6 +42,7 @@ def send_cache_data(): a.gameid, a.channelid, a.jump_status, + a.ad_property, b.area, b.type, b.mode, @@ -147,9 +86,7 @@ def send_cache_data(): if line: item = {} try: - item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ - 'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line + item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item['jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item['jump_status'],item['ad_property'], item['area'], item['type'], item['mode'], item['locationid'] = line all.append(item) except Exception: log.error("split data failed", exc_info=True) diff --git a/handler/ad.py b/handler/ad.py index 215dfaa..7fec084 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -38,6 +38,7 @@ parser.add_argument('ad_sort') parser.add_argument('status') parser.add_argument('companyid') parser.add_argument('jump_param') +parser.add_argument('ad_property') class Ad(Resource): def __init__(self): @@ -55,23 +56,120 @@ class Ad(Resource): # now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") if not id: if companyid: - sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ - f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ - f"b.area,b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and " \ - f"a.companyid={companyid};" + sel_sql = f"""select + a.id, + a.name, + a.begin_time, + a.end_time, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.status, + a.companyid, + a.locationid, + a.gameid, + a.channelid, + a.jump_status, + a.ad_property, + b.area, + b.type, + b.mode + from + ad a, + location b + where + a.locationid=b.id + and a.in_used=1 + and a.companyid={companyid};""" elif status or status == 0: - sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ - f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ - f"b.area,b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and \ - a.status={status};" + sel_sql = f"""select + a.id, + a.name, + a.begin_time, + a.end_time, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.status, + a.companyid, + a.locationid, + a.gameid, + a.channelid, + a.jump_status, + a.ad_property, + b.area, + b.type, + b.mode + from + ad a, + location b + where + a.locationid=b.id + and a.in_used=1 + and a.status={status};""" else: - sel_sql = f"SELECT a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ - f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status," \ - f"b.area,b.type,b.mode FROM ad a,location b WHERE a.locationid=b.id AND a.in_used=1 ;" + sel_sql = f"""select + a.id, + a.name, + a.begin_time, + a.end_time, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.status, + a.companyid, + a.locationid, + a.gameid, + a.channelid, + a.jump_status, + a.ad_property, + b.area, + b.type, + b.mode + from + ad a, + location b + where + a.locationid=b.id + and a.in_used=1 ;""" else: - sel_sql = f"select a.id,a.name,a.begin_time,a.end_time,a.ad_num,a.ad_title,a.ad_body,a.ad_image," \ - f"a.jump_param,a.ad_sort,a.status,a.companyid,a.locationid,a.gameid,a.channelid,a.jump_status,b.area," \ - f"b.type,b.mode from ad a,location b where a.locationid=b.id and a.in_used=1 and a.id={id};" + sel_sql = f"""select + a.id, + a.name, + a.begin_time, + a.end_time, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.status, + a.companyid, + a.locationid, + a.gameid, + a.channelid, + a.jump_status, + a.ad_property, + b.area, + b.type, + b.mode + from + ad a, + location b + where + a.locationid=b.id + and a.in_used=1 + and a.id={id}; """ data = self.mydb.query(sel_sql) log.info(f"sql={sel_sql},data={data}") if data: @@ -82,7 +180,7 @@ class Ad(Resource): 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['jump_param'], ad_info[ 'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info['gameid'], \ - ad_info['channelid'], ad_info['jump_status'], ad_info['area'], ad_info['type'], ad_info[ + ad_info['channelid'], ad_info['jump_status'],ad_info['ad_property'], ad_info['area'], ad_info['type'], ad_info[ 'mode'] = line all.append(ad_info) return jsonify({'code': 200, 'message': all}) @@ -110,6 +208,7 @@ class Ad(Resource): ad['jump_status'] = self.args['jump_status'] ad['ad_sort'] = self.args['ad_sort'] or 0 ad['companyid'] = self.args['companyid'] + ad['ad_property'] = self.args['ad_property'] # 检查必需有的字段 if not ( ad['name'] and ad['gameid'] and ad['locationid'] and ad['ad_image'] and ad['jump_status'] and ad['companyid']): @@ -162,6 +261,7 @@ class Ad(Resource): ad['status'] = self.args['status'] or 0 ad['companyid'] = self.args['companyid'] ad['jump_status'] = self.args['jump_status'] + ad['ad_property'] = self.args['ad_property'] sel_sql = f"select name from ad where id={self.args['id']};" data = self.mydb.query(sel_sql) From 5d5a47e24044c9781dc45dfd4e0894555a6c9f1d Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 11:50:28 +0800 Subject: [PATCH 42/47] =?UTF-8?q?=E4=B8=BA=E5=B9=BF=E5=91=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=20ad=5Fproperty=20=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAjson=E5=AD=98=E5=82=A8=E5=B9=BF=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 1 + 1 file changed, 1 insertion(+) diff --git a/handler/ad.py b/handler/ad.py index 7fec084..5a4dd75 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -263,6 +263,7 @@ class Ad(Resource): ad['jump_status'] = self.args['jump_status'] ad['ad_property'] = self.args['ad_property'] + sel_sql = f"select name from ad where id={self.args['id']};" data = self.mydb.query(sel_sql) if data: From db4d37f12bbbc9be6f4bb0774eda17ce6b05711b Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 13:48:21 +0800 Subject: [PATCH 43/47] =?UTF-8?q?=E4=B8=BA=E5=B9=BF=E5=91=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=20ad=5Fproperty=20=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAjson=E5=AD=98=E5=82=A8=E5=B9=BF=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 2 +- ad_tasks.py | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 ad_tasks.py diff --git a/README.MD b/README.MD index 0f21d47..d4274ff 100644 --- a/README.MD +++ b/README.MD @@ -330,7 +330,7 @@ http://154.8.214.202:5015/interface/prometion ##### 请求示范 -http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2 +http://154.8.214.202:5015/interface/promotion?name=abc&gameid=1003&locationid=1007&ad_title=hello&ad_body=hi world&ad_image=http://1&ad_url=http://2&companyid=2&ad_property={‘is_shake’:1}&jump_status=1 ##### 请求参数说明 diff --git a/ad_tasks.py b/ad_tasks.py new file mode 100644 index 0000000..085db25 --- /dev/null +++ b/ad_tasks.py @@ -0,0 +1,160 @@ +# -*- coding: utf-8 -*- +from myredis.myredis import my_redis +import datetime +from mysql.mmysql import MysqlBase +from config import mysql_promotion_config +from log.mylog import define_logger +import logging +from config import BEGIN, END, ad_list_interface_port +import pdb + +define_logger("/data/logs/ad_tasks.log") +log = logging.getLogger(__name__) + +limit = 10 + + +def send_cache_data(): + mydb = MysqlBase(**mysql_promotion_config) + log.info("start update cache !") + now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") + all = [] + + get_data_sql = f"""select + a.id, + a.name, + a.ad_num, + a.ad_title, + a.ad_body, + a.ad_image, + a.jump_param, + a.ad_sort, + a.companyid, + a.gameid, + a.channelid, + a.jump_status, + a.ad_property, + b.area, + b.type, + b.mode, + a.locationid + from + (select + id, + name, + ad_num, + ad_title, + ad_body, + ad_image, + jump_param, + ad_sort, + companyid, + gameid, + channelid, + jump_status, + locationid + from + ad + where + status=1 + and in_used=1 + and '{now}'> begin_time + and '{now}' 0: + num = my_redis.get(f"ad::{line['id']}::num") + if not num: + num = 0 + if int(line['ad_num']) > int(num): + my_redis.sadd(key, line['id']) + my_redis.expire(key, 120) + n = int(line['ad_num']) - int(num) + log.info(f"add {line['id']} to {key} ,num was {line['ad_num']},limit was {n}!") + else: + if my_redis.sismember(key, line['id']): + my_redis.srem(key, line['id']) + log.info(f"remove {line['id']} from {key}!") + elif int(line['ad_num']) == 0: + my_redis.sadd(key, line['id']) + my_redis.expire(key, 120) + log.info(f"add {line['id']} to {key} ,num was unlimit !") + else: + log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}") + + if not my_redis.exists(f"ad::{line['id']}::info"): + # remove some filed from adinfo + remove_list = ('ad_num', 'gameid') + for item in remove_list: + line.pop(item) + my_redis.hmset(f"ad::{line['id']}::info", line) + my_redis.expire(f"ad::{line['id']}::info", 120) + # my_redis.expire(f"ad::{line['id']}::info", 3600 * 24 * 7) + log.info(f"add ad::{line['id']}::info to redis!") + + # 删除过期的数据 + log.info("remove expire data from cache!") + + expire_sql = f"""select + a.id,a.gameid,a.channelid,a.locationid,a.status,b.area + from + (select + id,gameid,channelid,locationid,status + from + ad + where + '{now}'> end_time + or status in (3,4) ) a , + (select + id, + area + from + location) b + where + a.locationid=b.id""" + remove_data = mydb.query(expire_sql) + if remove_data: + for line in remove_data: + try: + id, gameid, channelid, locationid, _, area = line + key = f"ad::{gameid}::{channelid}::{area.split(',')[0].strip()}::{locationid}" + # key = f"{gameid}:{locationid}" + if my_redis.sismember(key, id): + my_redis.srem(key, id) + my_redis.expire(f"ad::{id}::info", 1) + log.info(f"remove {id} from {key} success!") + except Exception: + log.error("拆解过期数据出错!", exc_info=True) + + +if __name__ == "__main__": + log.info('start!') + send_cache_data() From 84796cc13b1fe3bea80cb561dda5401e146449a5 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 13:48:48 +0800 Subject: [PATCH 44/47] =?UTF-8?q?=E4=B8=BA=E5=B9=BF=E5=91=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=20ad=5Fproperty=20=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAjson=E5=AD=98=E5=82=A8=E5=B9=BF=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ad_tasks.py b/ad_tasks.py index 085db25..7f7d9d7 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -88,8 +88,7 @@ def send_cache_data(): if all: # log.info(f"get data was {all}!\n") for line in all: - key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[ - 0].strip()}::{line.get('locationid', 0)}" + key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0].strip()}::{line.get('locationid', 0)}" if int(line['ad_num']) > 0: num = my_redis.get(f"ad::{line['id']}::num") if not num: From c1d9d72617afdc8109faa231d7467c94d088a970 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 13:56:45 +0800 Subject: [PATCH 45/47] =?UTF-8?q?=E4=B8=BA=E5=B9=BF=E5=91=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=20ad=5Fproperty=20=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAjson=E5=AD=98=E5=82=A8=E5=B9=BF=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index 7f7d9d7..8455145 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -52,7 +52,8 @@ def send_cache_data(): gameid, channelid, jump_status, - locationid + locationid , + ad_property from ad where From daa3e20de81fb4905964b2cad4bf8a4bb8440f26 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 8 Aug 2019 13:59:15 +0800 Subject: [PATCH 46/47] =?UTF-8?q?=E4=B8=BA=E5=B9=BF=E5=91=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=20ad=5Fproperty=20=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAjson=E5=AD=98=E5=82=A8=E5=B9=BF=E5=91=8A=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 138 ---------------------------------------- ad_tasks.py | 3 +- 2 files changed, 2 insertions(+), 139 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 09ee7de..9e20532 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -23,142 +23,6 @@ log = logging.getLogger(__name__) limit = 10 -def send_cache_data(): - mydb = MysqlBase(**mysql_promotion_config) - log.info("start update cache !") - now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") - all = [] - - get_data_sql = f"""select - a.id, - a.name, - a.ad_num, - a.ad_title, - a.ad_body, - a.ad_image, - a.jump_param, - a.ad_sort, - a.companyid, - a.gameid, - a.channelid, - a.jump_status, - a.ad_property, - b.area, - b.type, - b.mode, - a.locationid - from - (select - id, - name, - ad_num, - ad_title, - ad_body, - ad_image, - jump_param, - ad_sort, - companyid, - gameid, - channelid, - jump_status, - locationid - from - ad - where - status=1 - and in_used=1 - and '{now}'> begin_time - and '{now}' 0: - num = my_redis.get(f"ad::{line['id']}::num") - if not num: - num = 0 - if int(line['ad_num']) > int(num): - my_redis.sadd(key, line['id']) - my_redis.expire(key, 120) - n = int(line['ad_num']) - int(num) - log.info(f"add {line['id']} to {key} ,num was {line['ad_num']},limit was {n}!") - else: - if my_redis.sismember(key, line['id']): - my_redis.srem(key, line['id']) - log.info(f"remove {line['id']} from {key}!") - elif int(line['ad_num']) == 0: - my_redis.sadd(key, line['id']) - my_redis.expire(key, 120) - log.info(f"add {line['id']} to {key} ,num was unlimit !") - else: - log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}") - - if not my_redis.exists(f"ad::{line['id']}::info"): - # remove some filed from adinfo - remove_list = ('ad_num', 'gameid') - for item in remove_list: - line.pop(item) - my_redis.hmset(f"ad::{line['id']}::info", line) - my_redis.expire(f"ad::{line['id']}::info", 120) - # my_redis.expire(f"ad::{line['id']}::info", 3600 * 24 * 7) - log.info(f"add ad::{line['id']}::info to redis!") - - # 删除过期的数据 - log.info("remove expire data from cache!") - - expire_sql = f"""select - a.id,a.gameid,a.channelid,a.locationid,a.status,b.area - from - (select - id,gameid,channelid,locationid,status - from - ad - where - '{now}'> end_time - or status in (3,4) ) a , - (select - id, - area - from - location) b - where - a.locationid=b.id""" - remove_data = mydb.query(expire_sql) - if remove_data: - for line in remove_data: - try: - id, gameid, channelid, locationid, _, area = line - key = f"ad::{gameid}::{channelid}::{area.split(',')[0].strip()}::{locationid}" - # key = f"{gameid}:{locationid}" - if my_redis.sismember(key, id): - my_redis.srem(key, id) - my_redis.expire(f"ad::{id}::info", 1) - log.info(f"remove {id} from {key} success!") - except Exception: - log.error("拆解过期数据出错!", exc_info=True) - class DispatchHandler(tornado.web.RequestHandler): @gen.coroutine @@ -263,8 +127,6 @@ def make_app(): if __name__ == "__main__": print('start!') - send_cache_data() app = make_app() app.listen(ad_list_interface_port) - tornado.ioloop.PeriodicCallback(send_cache_data, 60000).start() tornado.ioloop.IOLoop.current().start() diff --git a/ad_tasks.py b/ad_tasks.py index 8455145..0a27b3e 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -70,7 +70,7 @@ def send_cache_data(): location) b where a.locationid=b.id""" - pdb.set_trace() + data = mydb.query(get_data_sql) if data: for line in data: @@ -86,6 +86,7 @@ def send_cache_data(): except Exception: log.error("split data failed", exc_info=True) # 检查ID是否存在播放列表中,以及播放次数是否完毕 + pdb.set_trace() if all: # log.info(f"get data was {all}!\n") for line in all: From 6e5b56e1f53a0da5d470390653689d7507b00dea Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Aug 2019 14:35:28 +0800 Subject: [PATCH 47/47] fix --- ad_tasks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index 0a27b3e..e3bef5b 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -86,7 +86,6 @@ def send_cache_data(): except Exception: log.error("split data failed", exc_info=True) # 检查ID是否存在播放列表中,以及播放次数是否完毕 - pdb.set_trace() if all: # log.info(f"get data was {all}!\n") for line in all: