wwwlll Kevin Hu commited on
Commit
36a516d
·
1 Parent(s): 4efca68

Add API to get doc info by doc ids (#1986)

Browse files

Supports use API to get doc info by doc ids

### What problem does this PR solve?

feat: Supports use API to get doc info by doc ids

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: Kevin Hu <[email protected]>

Files changed (1) hide show
  1. api/apps/api_app.py +13 -0
api/apps/api_app.py CHANGED
@@ -571,6 +571,19 @@ def list_kb_docs():
571
  except Exception as e:
572
  return server_error_response(e)
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
  @manager.route('/document', methods=['DELETE'])
576
  # @login_required
 
571
  except Exception as e:
572
  return server_error_response(e)
573
 
574
+ @manager.route('/document/infos', methods=['POST'])
575
+ @validate_request("doc_ids")
576
+ def docinfos():
577
+ token = request.headers.get('Authorization').split()[1]
578
+ objs = APIToken.query(token=token)
579
+ if not objs:
580
+ return get_json_result(
581
+ data=False, retmsg='Token is not valid!"', retcode=RetCode.AUTHENTICATION_ERROR)
582
+ req = request.json
583
+ doc_ids = req["doc_ids"]
584
+ docs = DocumentService.get_by_ids(doc_ids)
585
+ return get_json_result(data=list(docs.dicts()))
586
+
587
 
588
  @manager.route('/document', methods=['DELETE'])
589
  # @login_required