tfse-app-api-v0.2/cc_rating/CCRatingRoute.py

122 lines
3.0 KiB
Python

from flask import Blueprint, request
from CompanyUser.CompanyUserAuth import verify_token, verify_real_company
from Utils.ErrorUtil import ReturnConditionCheckFailed
from cc_rating.CCRatingImpl import RatingImpl
cc_route = Blueprint('input', __name__)
@cc_route.route('/rating_records', methods=['GET'])
@verify_token
def rating_records_route(**kwargs):
"""
获取企业评价记录
Parameters:
cid 企业ID
Returns:
info 信息
result 记录
"""
try:
rating = RatingImpl()
rating.cid = kwargs['cid']
result = rating.records()
status = 200 if result else 210
return {"info": "评价记录", "result": result}, status
except ReturnConditionCheckFailed as e:
e.log_error()
return {"info": e.__str__()}, e.status_code
@cc_route.route('/start_general_rating_input', methods=['GET'])
@verify_token
@verify_real_company
def start_cc_rating_route(**kwargs):
"""
开始综合评
Parameters:
cid 企业ID
Returns:
info 信息
result 记录
"""
try:
rating = RatingImpl()
rating.cid = kwargs['cid']
info, result = rating.start_cc_rating()
return {"info": info, "result": result}, 200
except ReturnConditionCheckFailed as e:
e.log_error()
return {"info": e.__str__()}, e.status_code
@cc_route.route('/save_general_input_form', methods=['POST'])
@verify_token
def save_cc_rating_input_route(**kwargs):
"""
保存综合填报数据
Parameters:
cid 企业ID
Returns:
info: 信息
"""
try:
rating = RatingImpl()
rating.cid = kwargs['cid']
info = rating.save_cc_rating_input(request.json['input_form'])
return {"info": info}, 200
except ReturnConditionCheckFailed as e:
e.log_error()
return {"info": e.__str__()}, e.status_code
@cc_route.route('/submit_general_rating_input', methods=['GET'])
@verify_token
def submit_general_rating_input(**kwargs):
"""
提交填报数据,开始评
Parameters:
cid 企业ID
Returns:
res: desc
"""
try:
rating = RatingImpl()
rating.cid = kwargs['cid']
info, status = rating.exec_cc_rating()
return {"info": info}, status
except ReturnConditionCheckFailed as e:
e.log_error()
return {"info": e.__str__()}, e.status_code
@cc_route.route('choose_industry', methods=['GET'])
@verify_token
def choose_industry_route(**kwargs):
"""
行业选择接口
Parameters:
-
Returns:
-
"""
cc_rating = RatingImpl()
result = cc_rating.choose_industry()
return {"info": "查询成功", "result": result}
@cc_route.route('questionnaire', methods=['GET'])
@verify_token
def questionnaire(**kwargs):
"""
问卷接口
Parameters:
-
Returns:
-
"""
rating = RatingImpl()
rating.cid = kwargs['cid']
result = rating.questionnaire_obj()
return {"info": "行业问卷", "result": result}