兼容不同文档类型
Showing
2 changed files
with
20 additions
and
1 deletions
... | @@ -7,6 +7,7 @@ from . import consts | ... | @@ -7,6 +7,7 @@ from . import consts |
7 | from prese.compare import pre_compare, get_empty_result | 7 | from prese.compare import pre_compare, get_empty_result |
8 | from common.mixins import LoggerMixin | 8 | from common.mixins import LoggerMixin |
9 | from settings import conf | 9 | from settings import conf |
10 | from pos.consts import DocumentType | ||
10 | 11 | ||
11 | 12 | ||
12 | class MPOSHandler: | 13 | class MPOSHandler: |
... | @@ -255,6 +256,6 @@ class PosHandler: | ... | @@ -255,6 +256,6 @@ class PosHandler: |
255 | 256 | ||
256 | doc_type = file_obj.get('documentType', '') | 257 | doc_type = file_obj.get('documentType', '') |
257 | img_base64 = file_obj.get('fileBase64') | 258 | img_base64 = file_obj.get('fileBase64') |
258 | if doc_type == 'Greenbook': | 259 | if doc_type == DocumentType.GREEN_BOOK.value.en_name: |
259 | PosHandler.greenbook_process(result_obj, img_base64) | 260 | PosHandler.greenbook_process(result_obj, img_base64) |
260 | return result_obj | 261 | return result_obj | ... | ... |
src/pos/consts.py
0 → 100644
1 | from enum import Enum | ||
2 | |||
3 | |||
4 | class DocumentTypeModel: | ||
5 | def __init__(self, code, en_name, cn_name): | ||
6 | self.code = code; | ||
7 | self.en_name = en_name | ||
8 | self.cn_name = cn_name | ||
9 | |||
10 | |||
11 | class DocumentType(Enum): | ||
12 | GREEN_BOOK = DocumentTypeModel("DTGBK", "Green Book", "机动车登记证") | ||
13 | CONFIRMATION_LETTER = DocumentTypeModel("DTCLE", "Confirmation Letter", "解抵押确认函") | ||
14 | WEBSITE_SCREENSHOT = DocumentTypeModel("DTWES", "Website Screenshot", "网页截图") | ||
15 | |||
16 | |||
17 | if __name__ == '__main__': | ||
18 | print(DocumentType.GREEN_BOOK.value.en_name) |
-
Please register or sign in to post a comment