Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f1694401
authored
2025-07-09 14:50:01 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
MOD:invoice-api
1 parent
820e4b70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
src/apps/doc/views.py
src/common/response2.py
src/apps/doc/views.py
View file @
f169440
...
...
@@ -17,6 +17,7 @@ from webargs import fields, validate
from
webargs.djangoparser
import
use_args
,
parser
from
settings
import
conf
from
common
import
response
from
common
import
response2
from
common.mixins
import
GenericView
,
DocGenericView
from
common.tools.file_tools
import
file_write
from
common.redis_cache
import
redis_handler
as
rh
...
...
@@ -1964,8 +1965,8 @@ class InvoiceExcelView(GenericView):
#authentication_classes = [OAuth2AuthenticationWithUser]
# 下载发票excel
@use_args
(
invoice_download_args
,
location
=
'
querystring
'
)
def
ge
t
(
self
,
request
,
args
):
@use_args
(
invoice_download_args
,
location
=
'
data
'
)
def
pos
t
(
self
,
request
,
args
):
application_ids
=
args
.
get
(
'application_ids'
)
application_entity
=
args
.
get
(
'application_entity'
)
self
.
running_log
.
info
(
'[InvoiceExcelView] [user_role={0}] '
.
format
(
'111222333'
))
...
...
@@ -2009,8 +2010,8 @@ class InvoiceQueryInfoView(GenericView):
#permission_classes = [IsAuthenticated]
#authentication_classes = [OAuth2AuthenticationWithUser]
@use_args
(
invoice_download_args
,
location
=
'
querystring
'
)
def
ge
t
(
self
,
request
,
args
):
@use_args
(
invoice_download_args
,
location
=
'
data
'
)
def
pos
t
(
self
,
request
,
args
):
application_ids
=
args
.
get
(
'application_ids'
)
application_entity
=
args
.
get
(
'application_entity'
)
self
.
running_log
.
info
(
'[InvoiceExcelView] [user_role={0}] '
.
format
(
'111222333'
))
...
...
@@ -2037,7 +2038,7 @@ class InvoiceQueryInfoView(GenericView):
self
.
running_log
.
info
(
"java invoice info api finish, applicationIds:{0},{1}"
.
format
(
application_ids
,
resp
.
text
))
res_json
=
json
.
loads
(
resp
.
text
)
java_result
=
res_json
.
get
(
'result'
)
return
response
.
ok
(
data
=
java_result
)
return
response
2
.
ok
(
data
=
java_result
)
except
Exception
as
e
:
self
.
running_log
.
error
(
"invoice info request to java error, url:{0}, param:{1}, errorMsg:{2}"
.
format
(
url
,
json
.
dumps
(
body
),
traceback
.
format_exc
()))
...
...
src/common/response2.py
0 → 100644
View file @
f169440
import
enum
from
django.http
import
JsonResponse
,
HttpResponse
from
.named_enum
import
NamedEnum
def
res_content
(
meta_status
,
msg
,
data
=
None
):
res
=
{
'code'
:
meta_status
,
'msg'
:
msg
}
if
data
is
not
None
:
res
[
'result'
]
=
data
return
res
@enum.unique
class
MetaStatus
(
NamedEnum
):
SUCCESS
=
(
0
,
'success'
)
NEED_LOGIN
=
(
1
,
'need login'
)
INVALID_PARAMS
=
(
2
,
'invalid params'
)
INTERNAL_ERROR
=
(
3
,
'internal error'
)
NOT_EXIST
=
(
4
,
'object not exist'
)
ASYNC_WAIT
=
(
5
,
'async wait'
)
NO_PERMISSION
=
(
6
,
'no permission'
)
ILLEGAL_OPERATION
=
(
7
,
'illegal operation'
)
NEED_UPDATE
=
(
8
,
'need update'
)
class
APIResponse
(
JsonResponse
):
def
__init__
(
self
,
meta_status
,
data
=
None
,
msg
=
''
,
json_dumps_params
=
None
,
**
kwargs
):
data
=
res_content
(
meta_status
,
msg
,
data
)
json_dumps_params
=
json_dumps_params
or
{
'ensure_ascii'
:
False
}
kwargs
[
'json_dumps_params'
]
=
json_dumps_params
super
()
.
__init__
(
data
,
**
kwargs
)
def
ok
(
**
kwargs
):
return
APIResponse
(
10000
,
msg
=
MetaStatus
.
SUCCESS
.
verbose_name
,
**
kwargs
)
def
error_msg
(
msg
=
'internal error'
,
**
kwargs
):
return
APIResponse
(
MetaStatus
.
INTERNAL_ERROR
.
value
,
msg
=
msg
,
**
kwargs
)
def
need_update
(
**
kwargs
):
return
APIResponse
(
MetaStatus
.
NEED_UPDATE
.
value
,
msg
=
MetaStatus
.
NEED_UPDATE
.
verbose_name
,
**
kwargs
)
def
excel_response
(
file_name
,
io_content
):
http_response
=
HttpResponse
(
content_type
=
"application/vnd.ms-excel"
)
http_response
[
'Content-Disposition'
]
=
'attachment;filename={0}.xlsx'
.
format
(
file_name
)
http_response
.
write
(
io_content
.
getvalue
())
return
http_response
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment