Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xianyang
financial-system
Commits
1d832e1a
Commit
1d832e1a
authored
Apr 20, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化创建账户
parent
00cf4ad1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+23
-9
crud.py
app/api/account/crud.py
+15
-5
schemas.py
app/api/account/schemas.py
+4
-4
views.py
app/api/account/views.py
+2
-0
result_format.py
libs/result_format.py
+2
-0
No files found.
app/api/account/crud.py
View file @
1d832e1a
...
...
@@ -154,12 +154,22 @@ def get_gift_type(unique_tag):
def
create_account
(
param
):
"""创建账户"""
income
=
','
.
join
(
map
(
str
,
param
.
income
))
output
=
','
.
join
(
map
(
str
,
param
.
output
))
clearing_dict
=
{
'description'
:
param
.
remark
,
# 描述信息
'unique_tag'
:
param
.
unique_tag
,
# 唯一标识
'beneficiary'
:
'platform-001'
,
# 受益人,也就是唯一标识
'config_key'
:
param
.
config_key
,
'name'
:
param
.
name
,
}
try
:
income
=
','
.
join
(
map
(
str
,
param
.
income
))
output
=
','
.
join
(
map
(
str
,
param
.
output
))
sql
=
f
"insert into fi_account(name, unique_tag, config_key, description, uuid, income, output, create_time) "
\
f
"values('{param.name}', '{param.unique_tag}', '{param.config_key}', '{param.remark}', '{uuid()}', '{income}', '{output}', {get_now_timestamp()});"
account
=
LinkMysql
(
env
.
DB_3YV2
)
.
perform_mysql
(
sql
)
result
=
search
(
clearing_dict
,
'Server.UserExecute.CreateBalanceUser'
)
if
result
[
'data'
][
'result'
][
'status'
]:
account_uuid
=
result
[
'data'
][
'result'
][
'data'
][
'uuid'
]
sql
=
f
"insert into fi_account(name, unique_tag, config_key, description, uuid, income, output, create_time) "
\
f
"values('{param.name}', '{param.unique_tag}', '{param.config_key}', '{param.remark}', '{account_uuid}', '{income}', '{output}', {get_now_timestamp()});"
account
=
LinkMysql
(
env
.
DB_3YV2
)
.
perform_mysql
(
sql
)
except
Exception
as
e
:
print
(
e
)
if
'config_key'
in
str
(
e
):
...
...
app/api/account/schemas.py
View file @
1d832e1a
...
...
@@ -12,10 +12,10 @@ class PublicModel(BaseModel):
class
AccountCreate
(
BaseModel
):
name
:
str
remark
:
Optional
[
str
]
=
None
unique_tag
:
str
config_key
:
Optional
[
str
]
=
None
name
:
Optional
[
str
]
=
''
remark
:
Optional
[
str
]
=
''
unique_tag
:
Optional
[
str
]
=
''
config_key
:
Optional
[
str
]
=
''
income
:
Optional
[
list
]
=
[]
output
:
Optional
[
list
]
=
[]
...
...
app/api/account/views.py
View file @
1d832e1a
...
...
@@ -17,6 +17,8 @@ router = APIRouter()
@
router
.
post
(
"/create"
)
def
create_account
(
data
:
schemas
.
AccountCreate
,
token
=
Depends
(
login_required
)):
"""添加账户"""
if
not
all
([
data
.
name
,
data
.
unique_tag
,
data
.
config_key
]):
return
HttpResultResponse
(
code
=
500
,
msg
=
HttpMessage
.
MISSING_PARAMETER
)
db_info
=
crud
.
get_account
(
data
.
name
)
if
db_info
:
return
HttpResultResponse
(
code
=
400
,
msg
=
HttpMessage
.
ACCOUNT_EXIST
)
...
...
libs/result_format.py
View file @
1d832e1a
...
...
@@ -23,6 +23,8 @@ class HttpMessage(object):
DELETE_LOSE
=
'删除失败'
LOSE
=
'操作失败'
MISSING_PARAMETER
=
"缺少必传参数"
class
DecimalEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
res
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment