modify get method

This commit is contained in:
RainSun 2020-02-14 15:55:08 +08:00
parent ce9ba5a48c
commit 7f4aa9e7d3
5 changed files with 13 additions and 21 deletions

View File

@ -73,24 +73,22 @@ kill (pid)
* total_addr
* detail_addr
* contact_way > type + content
* comment [ {msg, user_name, time, user_cid, reply } ]
* comment [ {msg, user_name, time, user_id, reply } ]
* user_info > user_cid + user_name + user_id
* type
* /api/laf/del
* data
* id
* type
* user_info > user_cid + user_name
* user_info > user_id + user_name
* /api/laf/get
* data
* user_info > user_cid + user_name
* /api/laf/detail
* data
* id
* type
* /api/laf/comment
* data
* user_info > user_cid + user_name
* user_info > user_id + user_name
* msg
* time
* position

2
coc.py
View File

@ -34,7 +34,7 @@ def laf_del():
# 获取全部失物招领信息
@app.route('/api/laf/get',methods=['POST'])
def laf_get():
res = manageGet(request)
res = manageGet()
return res
# 获取指定失物招领信息

View File

@ -61,16 +61,9 @@ def manageDel(request):
return {'errcode': 340, 'errmsg': '数据校验失败'}
# 获取全部失物招领信息
def manageGet(request):
# json化应该能当dict用
data_cache = json.loads(request.form['data'])
# MD5校验
checked = checkData(data_cache)
data_cache.pop('sign')
if checked:
return {'errcode': 200, 'lost': getLost(), 'found': getFound()}
else:
return {'errcode': 350, 'errmsg': '数据校验失败'}
def manageGet():
return {'errcode': 200, 'lost': getLost(), 'found': getFound()}
# 获取指定失物招领信息
def manageDetail(request):
@ -87,7 +80,7 @@ def manageDetail(request):
# 处理新增评论
def manageComment(request):
# json化应该能当dict用
data_cache = json.loads(request.form['data'])
data_cache = json.loads(request.form['comment_msg'])
# MD5校验
checked = checkData(data_cache)
data_cache.pop('sign')

View File

@ -33,7 +33,7 @@ def addLAF(data, add_type):
def getLost():
arr = []
try:
for i in col('lost').find():
for i in col('lost').find({'close':'false'},{'title': 1, 'create_time':1, 'img_url':1, 'total_addr':1,'type':1}):
arr.append(i)
except Exception as e:
return {'errcode': 351, 'errmsg': 'lost表获取失败', 'errdetail': e}
@ -43,7 +43,7 @@ def getLost():
def getFound():
arr = []
try:
for i in col('found').find():
for i in col('found').find({'close':'false'},{'title': 1, 'create_time':1, 'img_url':1, 'total_addr':1,'type':1}):
arr.append(i)
except Exception as e:
return {'errcode': 352, 'errmsg': 'found表获取失败', 'errdetail': e}
@ -52,7 +52,7 @@ def getFound():
# 获取指定失物信息
def getDetail(id, get_type, errcode):
try:
info = col(get_type).find_one({"_id": ObjectId(id)})
info = col(get_type).find_one({"_id": ObjectId(id)},{'user_info':0})
if info:
return {'errcode': 200, 'detail': json_util.dumps(info), 'errmsg': 'ok'}
else:
@ -64,10 +64,11 @@ def getDetail(id, get_type, errcode):
# 删除某个失物
def delLAF(id, del_type, del_user_info):
try:
col(laf_type).update({"_id": ObjectId(id)},
col(del_type).update({"_id": ObjectId(id)},
{'$set': {'close': 'true','del_user_info': del_user_info}})
except Exception as e:
# id不合法
print(e)
return {'errcode': 341, 'errmsg': 'id不合法'}
return {'errcode': 200, 'errmsg': 'ok'}

BIN
upload/no_img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB