02dfaa1f by 王聪

增加权限校验类

1 parent 7cd920c4
...@@ -5,6 +5,8 @@ from apps.doc.views import CustomDecimal, CustomDate ...@@ -5,6 +5,8 @@ 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 from rest_framework.permissions import IsAuthenticated
9 from apps.account.authentication import OAuth2AuthenticationWithUser
8 10
9 params = { 11 params = {
10 'invoiceCode': fields.Str(required=True, validate=validate.Length(max=128)), 12 'invoiceCode': fields.Str(required=True, validate=validate.Length(max=128)),
...@@ -28,6 +30,9 @@ input_args = { ...@@ -28,6 +30,9 @@ input_args = {
28 30
29 # poss 接口接收NSC 发票信息 31 # poss 接口接收NSC 发票信息
30 class NSCInvoiceView(GenericView): 32 class NSCInvoiceView(GenericView):
33 permission_classes = [IsAuthenticated]
34 authentication_classes = [OAuth2AuthenticationWithUser]
35
31 @use_args(input_args, location='data') 36 @use_args(input_args, location='data')
32 def post(self, request, args): # interface_report mpos to ocr 37 def post(self, request, args): # interface_report mpos to ocr
33 content = args.get('content', {}) 38 content = args.get('content', {})
...@@ -63,46 +68,46 @@ de_mortgage_comments = { ...@@ -63,46 +68,46 @@ de_mortgage_comments = {
63 68
64 69
65 # 解除抵押识别处理 70 # 解除抵押识别处理
66 class DeMortgageView(GenericView): 71 # class DeMortgageView(GenericView):
67 @use_args(de_mortgage_args, location='data') 72 # @use_args(de_mortgage_args, location='data')
68 def post(self, request, args): # interface_report mpos to ocr 73 # def post(self, request, args): # interface_report mpos to ocr
69 img_files = args.get('file_base64', []) 74 # img_files = args.get('file_base64', [])
70 customer_name = args.get('customerName', '') 75 # customer_name = args.get('customerName', '')
71 application = args.get('application', '') 76 # application = args.get('application', '')
72 de_mortgage_date = args.get('deMortgageDate') 77 # de_mortgage_date = args.get('deMortgageDate')
73 78 #
74 fields_input = { 79 # fields_input = {
75 'customerName': customer_name, 80 # 'customerName': customer_name,
76 'application': application, 81 # 'application': application,
77 'deMortgageDate': de_mortgage_date 82 # 'deMortgageDate': de_mortgage_date
78 } 83 # }
79 de_mortgage_info = {} 84 # de_mortgage_info = {}
80 # 绿本必须分开ocr 85 # # 绿本必须分开ocr
81 for img_file in img_files: 86 # for img_file in img_files:
82 info = PosHandler.de_mortgage_ocr_process(img_file) 87 # info = PosHandler.de_mortgage_ocr_process(img_file)
83 de_mortgage_info.update(info) 88 # de_mortgage_info.update(info)
84 89 #
85 request_pass = True 90 # request_pass = True
86 fields_result = [] 91 # fields_result = []
87 for field_name, input_val in enumerate(fields_input): 92 # for field_name, input_val in enumerate(fields_input):
88 field_result = { 93 # field_result = {
89 "name": field_name, 94 # "name": field_name,
90 "input": input_val, 95 # "input": input_val,
91 "ocr": de_mortgage_info.get(field_name, ''), 96 # "ocr": de_mortgage_info.get(field_name, ''),
92 "field_is_pass": False, 97 # "field_is_pass": False,
93 "comments": '' 98 # "comments": ''
94 } 99 # }
95 result, _ = cp.common_compare(field_result['input'], field_result['ocr']) 100 # result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
96 if result == cp.RESULT_Y: 101 # if result == cp.RESULT_Y:
97 fields_result['field_is_pass'] = result 102 # fields_result['field_is_pass'] = result
98 else: 103 # else:
99 request_pass = False 104 # request_pass = False
100 fields_result['comments'] = de_mortgage_comments.get(field_name, '') 105 # fields_result['comments'] = de_mortgage_comments.get(field_name, '')
101 106 #
102 fields_result.append(field_result) 107 # fields_result.append(field_result)
103 108 #
104 result = { 109 # result = {
105 "is_pass": request_pass, 110 # "is_pass": request_pass,
106 "fields": fields_result 111 # "fields": fields_result
107 } 112 # }
108 return response.ok(data=result) 113 # 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!