调整ad数据库的字段
This commit is contained in:
parent
25f785452b
commit
68d493df18
97
ad_Readme.md
Normal file
97
ad_Readme.md
Normal file
@ -0,0 +1,97 @@
|
||||
#### 1、返回广告列表信息
|
||||
|
||||
##### 接口地址
|
||||
|
||||
http://ad.kingsome.cn/webapp/index.php
|
||||
|
||||
##### 返回格式:json
|
||||
|
||||
##### 请求方式:get
|
||||
|
||||
##### 请求示范
|
||||
|
||||
http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003:6001","locationid":1001}
|
||||
|
||||
##### 请求参数说明
|
||||
|
||||
| 名称 | 类型 | 必填 | 说明 |
|
||||
| --------- | ---- | ---- | ---------------------------------- |
|
||||
| c | string | 是 | OPS通用接口标志 |
|
||||
| a | string | 是 | 方法定义 当前为getAdList |
|
||||
| body | string | 是 | 参数体,JSON格式,gameid,locationid作为key |
|
||||
|
||||
##### 返回参数说明
|
||||
|
||||
| 名称 | 类型 | 必填 | 说明 |
|
||||
| ---- | ---- | ---- | -------- |
|
||||
| errcode | int | 是 | 返回状态 |
|
||||
| errmsg | string | 是 | 错误信息 |
|
||||
| ad_title | string | 是 | 广告标题 |
|
||||
| ad_body | string | 是 | 广告正文 |
|
||||
| ad_image | string | 是 | 广告图片 |
|
||||
| ad_sort | int | 是 | 播放优先级 |
|
||||
| adid | int | 是 | 广告标志ID,用途数据上传统计 |
|
||||
| name | string | 是 | 广告名称 |
|
||||
| jump_status | int | 是 | 跳转状态,1=跳转,0=不跳 |
|
||||
| jump_param | string | 是 | 跳转参数 |
|
||||
|
||||
|
||||
##### 返回示例
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "",
|
||||
"message": {
|
||||
"totoal": 3,
|
||||
"result": [
|
||||
{
|
||||
"ad_body": "2",
|
||||
"ad_image": "https://resource.kingsome.cn//ad/0e04000e-a865-11e9-a181-525400ddcafb_512icon(1)(1).png",
|
||||
"ad_num": "40",
|
||||
"ad_sort": "0",
|
||||
"ad_title": "2",
|
||||
"ad_url": "sdfd",
|
||||
"companyid": "1002",
|
||||
"gameid": "1004",
|
||||
"adid": "1010",
|
||||
"locationid": "1001",
|
||||
"name": "22"
|
||||
},
|
||||
|
||||
#### 2、广告播放上报
|
||||
|
||||
##### 接口地址
|
||||
|
||||
http://ad.kingsome.cn/webapp/index.php
|
||||
|
||||
##### 返回格式:json
|
||||
|
||||
##### 请求方式:get
|
||||
|
||||
##### 请求示范
|
||||
|
||||
http://ad.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009
|
||||
|
||||
##### 请求参数说明
|
||||
|
||||
| 名称 | 类型 | 必填 | 说明 |
|
||||
| --------- | ---- | ---- | ---------------------------------- |
|
||||
| c | string | 是 | OPS通用接口标志 |
|
||||
| a | string | 是 | 方法定义 upAdRecording |
|
||||
| adid | int | 是 | 广告ID |
|
||||
|
||||
##### 返回参数说明
|
||||
|
||||
| 名称 | 类型 | 必填 | 说明 |
|
||||
| ---- | ---- | ---- | -------- |
|
||||
| errcode | int | 是 | 返回状态 |
|
||||
| errmsg | string | 是 | 错误信息 |
|
||||
| message | string | 是 | 返回信息 |
|
||||
|
||||
|
||||
|
||||
##### 返回示例
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "",
|
||||
"message": "1002 incr success!"
|
||||
}
|
@ -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.ad_url,a.ad_sort,a.companyid,a.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id 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.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and a.begin_time='{BEGIN}' or a.end_time='{END}'"
|
||||
full_data = mydb.query(get_full_data)
|
||||
|
||||
if full_data:
|
||||
@ -38,14 +38,14 @@ def send_cache_data():
|
||||
item = {}
|
||||
try:
|
||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
||||
'ad_url'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[
|
||||
'jump_param'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[
|
||||
'appid'] = 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.ad_url,a.ad_sort,a.companyid,a.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and '{now}'>a.begin_time and '{now}'<a.end_time ;"
|
||||
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.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and '{now}'>a.begin_time and '{now}'<a.end_time ;"
|
||||
|
||||
data = mydb.query(get_data_sql)
|
||||
if data:
|
||||
@ -54,7 +54,7 @@ def send_cache_data():
|
||||
item = {}
|
||||
try:
|
||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
||||
'ad_url'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[
|
||||
'jump_param'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[
|
||||
'appid'] = line
|
||||
all.append(item)
|
||||
except Exception:
|
||||
@ -86,6 +86,10 @@ def send_cache_data():
|
||||
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','appid','companyid','gameid','locationid')
|
||||
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", 3600 * 24 * 7)
|
||||
log.info(f"add ad::{line['id']}::info to redis!")
|
||||
|
Loading…
x
Reference in New Issue
Block a user