修改广告GET方法,添加按状态返回和按广告ID返回明细的功能

This commit is contained in:
pengtao 2019-07-11 10:20:06 +08:00
parent 8eefeb6bcd
commit f7630ad262
2 changed files with 37 additions and 4 deletions

View File

@ -420,12 +420,15 @@ http://192.168.100.20:8888/ad
##### 请求示范 ##### 请求示范
http://192.168.100.20:8888/ad?gameid=1003&locationid=1 http://192.168.100.20:8888/ad?id=1002
http://192.168.100.20:8888/ad?status=0
##### 请求参数说明 ##### 请求参数说明
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | --------------------------- | | ------ | ---- | ---- | --------------------------- |
| | int | 否 | 广告ID其优先级高于status |
| status | int | 否 | 审批状态默认为1已审批 | | status | int | 否 | 审批状态默认为1已审批 |
##### 返回参数说明 ##### 返回参数说明
@ -437,6 +440,36 @@ http://192.168.100.20:8888/ad?gameid=1003&locationid=1
##### 返回示例 ##### 返回示例
{ {
"code": 200 "code": 200,
"message": {
"ad_body": "hi world",
"ad_image": "http://1",
"ad_num": 300,
"ad_sort": 1,
"ad_title": "hello",
"ad_url": "http://2",
"begin_time": "Sat, 01 Jun 2019 00:00:00 GMT",
"end_time": "Sun, 01 Dec 2019 00:00:00 GMT",
"id": 1002,
"name": "abc",
"status": 0
}
}
{
"code": 200,
"message": {
"ad_body": "hi world",
"ad_image": "http://1",
"ad_num": 300,
"ad_sort": 1,
"ad_title": "hello",
"ad_url": "http://2",
"begin_time": "Sat, 01 Jun 2019 00:00:00 GMT",
"end_time": "Sun, 01 Dec 2019 00:00:00 GMT",
"id": 1002,
"name": "abc",
"status": 0
}
} }

View File

@ -49,7 +49,7 @@ class Ad(Resource):
# # log.error(f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid}") # # log.error(f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid}")
# return jsonify({'code': 500, "message": f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid},{status}"}) # return jsonify({'code': 500, "message": f"请输入必须的游戏ID和位置ID字段当前获得是{gameid},{localid},{status}"})
now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") # now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
if not id: if not id:
if status: if status:
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,status " \ sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,status " \
@ -77,7 +77,7 @@ class Ad(Resource):
else: else:
return jsonify({ return jsonify({
'code': 404, 'code': 404,
'message': f'ad not found with gameid={gameid},localid={localid},now={now},status={status}!' 'message': f'ad not found with id={id},status={status}!'
}) })