添加位置服务接口

This commit is contained in:
pengtao 2019-07-10 16:19:05 +08:00
parent 97b15fccd7
commit 76ec6ad4ac
2 changed files with 12 additions and 7 deletions

View File

@ -330,7 +330,7 @@ http://192.168.100.20:8888/ad
##### 请求示范
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
##### 请求参数说明
@ -408,15 +408,15 @@ http://192.168.100.20:8888/ad
##### 请求示范
http://192.168.100.20:8888/ad
http://192.168.100.20:8888/ad?gameid=1003&locationid=1
##### 请求参数说明
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ---- | ---- | ------ |
| gameid | int | 是 | 游戏ID |
| locationid | int | 是 | 位置ID |
| | | | |
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ---- | ---- | --------------------------- |
| gameid | int | 是 | 游戏ID |
| locationid | int | 是 | 位置ID |
| status | int | 否 | 审批状态默认为1已审批 |
##### 返回参数说明

View File

@ -83,6 +83,11 @@ class Ad(Resource):
ad['ad_image'] = self.args['ad_image']
ad['ad_url'] = self.args['ad_url']
ad['ad_sort'] = self.args['ad_sort'] or 0
# 检查该广告是否已存在
check_sql = f"select id from ad where name='{ad['name']} and gameid={ad['gameid']} and locationid={ad['locationid']}"
data = mydb.query(check_sql)
if data:
return jsonify({'code': 500, 'message': f"name={ad['name']} gameid={ad['gameid']} was in db!"})
try:
mydb.insert('ad', ad)
return jsonify({'code': 200})