This commit is contained in:
root 2019-07-25 14:42:46 +08:00
commit e56b354e8f
3 changed files with 53 additions and 40 deletions

View File

@ -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
}
"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=icon2=banner3=浮窗) |
| | int | 是 | 广告单播或轮播模式1=单播2=轮播) |
| mode | int | 是 | 广告单播或轮播模式1=单播2=轮播) |
| gameid | int | 是 | 游戏ID |
| channelid | int | 否 | 渠道ID默认是6001 |
@ -345,11 +359,11 @@ 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 |
| locationid | int | 是 | 位置ID通过该ID到localtion表中获得areatypemode信息 |
| ad_title | string | 是 | 广告标题 |
| ad_body | string | 是 | 广告正文 |
| ad_image | string | 是 | 头像链接 |

View File

@ -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}'<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.gameid,a.jump_status,b.area,b.type,b.mode from ad a ,location b \
where'{now}'>a.begin_time and '{now}'<a.end_time and a.locationid=b.id ;"""
data = mydb.query(get_data_sql)
if data:
@ -55,8 +58,7 @@ 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)

View File

@ -29,10 +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,mode from location where gameid={gameid} and \
channelid={channelid} 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:
print(f"1 {sql}")
data = self.mydb.query(sql)
except Exception:
log.error("get data from location failed!", exc_info=True)
@ -49,7 +47,7 @@ class Location(Resource):
del localtion
return jsonify({'code': 200, 'message': all_data})
else:
log.error(f"{data} not found in mysql !")
log.error(f"{sql} not found in mysql !")
return jsonify({'code': 200, 'message': ""})
@ -65,7 +63,6 @@ class Location(Resource):
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: