tfse-admin-api-v0.2/file/file_routes.py

88 lines
2.8 KiB
Python

from flask import Blueprint, request, Response
from file.file_obj import CreditRatingReportFile, CreditRatingCertificationFile, IndustryReportFile, \
CreditEsgReportFile, CreditESGCertificationFile
from user.user_auth import verify_token, authority_scope
file_route = Blueprint('file', __name__)
@file_route.route('/get_company_report', methods=['GET'])
@verify_token
@authority_scope(['admin', 'developer', 'analysts', 'operator', 'guest'])
def get_company_report_route(**kwargs):
"""
查看公司综合信用评价报告
"""
file = CreditRatingReportFile()
file.file_id = request.args.get('file_id')
file_stream = file.get_file()
if file_stream is not False:
return Response(file_stream, content_type='application/pdf')
else:
return {"info": "未找到文件"}, 404
@file_route.route('/get_company_esg_report', methods=['GET'])
@verify_token
@authority_scope(['admin', 'developer', 'analysts', 'operator', 'guest'])
def get_company_esg_report_route(**kwargs):
"""
查看公司ESG评价报告
"""
file = CreditEsgReportFile()
file.file_id = request.args.get('file_id')
file_stream = file.get_file()
if file_stream is not False:
return Response(file_stream, content_type='application/pdf')
else:
return {"info": "未找到文件"}, 404
@file_route.route('/get_certification', methods=['GET'])
@verify_token
@authority_scope(['admin', 'developer', 'analysts', 'operator', 'guest'])
def get_certification_route(**kwargs):
"""
查看公司综合信用评价证书
"""
file = CreditRatingCertificationFile()
file.file_id = request.args.get('file_id')
file_stream = file.get_file()
if file_stream is not False:
return Response(file_stream, content_type='application/pdf')
else:
return {"info": "未找到文件"}, 404
@file_route.route('/get_esg_certification', methods=['GET'])
@verify_token
@authority_scope(['admin', 'developer', 'analysts', 'operator', 'guest'])
def get_esg_certification_route(**kwargs):
"""
查看公司ESG评价证书
"""
file = CreditESGCertificationFile()
file.file_id = request.args.get('file_id')
file_stream = file.get_file()
if file_stream is not False:
return Response(file_stream, content_type='application/pdf')
else:
return {"info": "未找到文件"}, 404
@file_route.route('/get_industry_report', methods=['GET'])
@verify_token
@authority_scope(['admin', 'developer', 'analysts', 'operator', 'guest'])
def get_industry_report_route(**kwargs):
"""
查看行业报告
"""
file = IndustryReportFile()
file.file_id = request.args.get('file_id')
file_stream = file.get_file()
if file_stream is not False:
return Response(file_stream, content_type='application/pdf')
else:
return {"info": "未找到文件"}, 404