329ae9e3 by 王聪

增加权限校验类

1 parent 02dfaa1f
......@@ -5,6 +5,7 @@ from apps.doc.views import CustomDecimal, CustomDate
from common import response
from apps.doc.mixins import PosHandler
from common.tools.comparison import cp
from rest_framework.permissions import IsAuthenticated
from apps.account.authentication import OAuth2AuthenticationWithUser
......@@ -68,46 +69,50 @@ de_mortgage_comments = {
# 解除抵押识别处理
# class DeMortgageView(GenericView):
# @use_args(de_mortgage_args, location='data')
# def post(self, request, args): # interface_report mpos to ocr
# img_files = args.get('file_base64', [])
# customer_name = args.get('customerName', '')
# application = args.get('application', '')
# de_mortgage_date = args.get('deMortgageDate')
#
# fields_input = {
# 'customerName': customer_name,
# 'application': application,
# 'deMortgageDate': de_mortgage_date
# }
# de_mortgage_info = {}
# # 绿本必须分开ocr
# for img_file in img_files:
# info = PosHandler.de_mortgage_ocr_process(img_file)
# de_mortgage_info.update(info)
#
# request_pass = True
# fields_result = []
# for field_name, input_val in enumerate(fields_input):
# field_result = {
# "name": field_name,
# "input": input_val,
# "ocr": de_mortgage_info.get(field_name, ''),
# "field_is_pass": False,
# "comments": ''
# }
# result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
# if result == cp.RESULT_Y:
# fields_result['field_is_pass'] = result
# else:
# request_pass = False
# fields_result['comments'] = de_mortgage_comments.get(field_name, '')
#
# fields_result.append(field_result)
#
# result = {
# "is_pass": request_pass,
# "fields": fields_result
# }
# return response.ok(data=result)
class DeMortgageView(GenericView):
permission_classes = [IsAuthenticated]
authentication_classes = [OAuth2AuthenticationWithUser]
@use_args(de_mortgage_args, location='data')
def post(self, request, args): # interface_report mpos to ocr
img_files = args.get('file_base64', [])
customer_name = args.get('customerName', '')
application = args.get('application', '')
de_mortgage_date = args.get('deMortgageDate')
fields_input = {
'customerName': customer_name,
'application': application,
'deMortgageDate': de_mortgage_date
}
de_mortgage_info = {}
# 绿本必须分开ocr
for img_file in img_files:
info = PosHandler.de_mortgage_ocr_process(img_file)
de_mortgage_info.update(info)
request_pass = True
fields_result = []
for field_name, input_val in enumerate(fields_input):
field_result = {
"name": field_name,
"input": input_val,
"ocr": de_mortgage_info.get(field_name, ''),
"field_is_pass": False,
"comments": ''
}
result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
if result == cp.RESULT_Y:
fields_result['field_is_pass'] = result
else:
request_pass = False
fields_result['comments'] = de_mortgage_comments.get(field_name, '')
fields_result.append(field_result)
result = {
"is_pass": request_pass,
"fields": fields_result
}
return response.ok(data=result)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!