329ae9e3 by 王聪

增加权限校验类

1 parent 02dfaa1f
...@@ -5,6 +5,7 @@ from apps.doc.views import CustomDecimal, CustomDate ...@@ -5,6 +5,7 @@ from apps.doc.views import CustomDecimal, CustomDate
5 from common import response 5 from common import response
6 from apps.doc.mixins import PosHandler 6 from apps.doc.mixins import PosHandler
7 from common.tools.comparison import cp 7 from common.tools.comparison import cp
8
8 from rest_framework.permissions import IsAuthenticated 9 from rest_framework.permissions import IsAuthenticated
9 from apps.account.authentication import OAuth2AuthenticationWithUser 10 from apps.account.authentication import OAuth2AuthenticationWithUser
10 11
...@@ -68,46 +69,50 @@ de_mortgage_comments = { ...@@ -68,46 +69,50 @@ de_mortgage_comments = {
68 69
69 70
70 # 解除抵押识别处理 71 # 解除抵押识别处理
71 # class DeMortgageView(GenericView): 72 class DeMortgageView(GenericView):
72 # @use_args(de_mortgage_args, location='data') 73 permission_classes = [IsAuthenticated]
73 # def post(self, request, args): # interface_report mpos to ocr 74 authentication_classes = [OAuth2AuthenticationWithUser]
74 # img_files = args.get('file_base64', []) 75
75 # customer_name = args.get('customerName', '') 76 @use_args(de_mortgage_args, location='data')
76 # application = args.get('application', '') 77 def post(self, request, args): # interface_report mpos to ocr
77 # de_mortgage_date = args.get('deMortgageDate') 78 img_files = args.get('file_base64', [])
78 # 79 customer_name = args.get('customerName', '')
79 # fields_input = { 80 application = args.get('application', '')
80 # 'customerName': customer_name, 81 de_mortgage_date = args.get('deMortgageDate')
81 # 'application': application, 82
82 # 'deMortgageDate': de_mortgage_date 83 fields_input = {
83 # } 84 'customerName': customer_name,
84 # de_mortgage_info = {} 85 'application': application,
85 # # 绿本必须分开ocr 86 'deMortgageDate': de_mortgage_date
86 # for img_file in img_files: 87 }
87 # info = PosHandler.de_mortgage_ocr_process(img_file) 88 de_mortgage_info = {}
88 # de_mortgage_info.update(info) 89 # 绿本必须分开ocr
89 # 90 for img_file in img_files:
90 # request_pass = True 91 info = PosHandler.de_mortgage_ocr_process(img_file)
91 # fields_result = [] 92 de_mortgage_info.update(info)
92 # for field_name, input_val in enumerate(fields_input): 93
93 # field_result = { 94 request_pass = True
94 # "name": field_name, 95 fields_result = []
95 # "input": input_val, 96 for field_name, input_val in enumerate(fields_input):
96 # "ocr": de_mortgage_info.get(field_name, ''), 97 field_result = {
97 # "field_is_pass": False, 98 "name": field_name,
98 # "comments": '' 99 "input": input_val,
99 # } 100 "ocr": de_mortgage_info.get(field_name, ''),
100 # result, _ = cp.common_compare(field_result['input'], field_result['ocr']) 101 "field_is_pass": False,
101 # if result == cp.RESULT_Y: 102 "comments": ''
102 # fields_result['field_is_pass'] = result 103 }
103 # else: 104 result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
104 # request_pass = False 105 if result == cp.RESULT_Y:
105 # fields_result['comments'] = de_mortgage_comments.get(field_name, '') 106 fields_result['field_is_pass'] = result
106 # 107 else:
107 # fields_result.append(field_result) 108 request_pass = False
108 # 109 fields_result['comments'] = de_mortgage_comments.get(field_name, '')
109 # result = { 110
110 # "is_pass": request_pass, 111 fields_result.append(field_result)
111 # "fields": fields_result 112
112 # } 113 result = {
113 # return response.ok(data=result) 114 "is_pass": request_pass,
115 "fields": fields_result
116 }
117 return response.ok(data=result)
118
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!