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}'