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
3a593bb3
Commit
3a593bb3
authored
Mar 02, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增账目类型
parent
936f3778
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
crud.py
app/api/account/crud.py
+20
-1
schemas.py
app/api/account/schemas.py
+6
-0
views.py
app/api/account/views.py
+12
-0
result_format.py
libs/result_format.py
+1
-0
No files found.
app/api/account/crud.py
View file @
3a593bb3
...
...
@@ -165,7 +165,7 @@ def get_account_type(db: Session, data):
def
update_account_type
(
db
:
Session
,
data
):
"""修改账目类型"""
try
:
db
.
query
(
AccountType
)
.
filter
(
AccountType
.
id
==
data
.
id
)
.
update
({
AccountType
.
key_name
:
data
.
key_name
,
AccountType
.
key_value
:
data
.
key_value
,
...
...
@@ -175,3 +175,22 @@ def update_account_type(db: Session, data):
except
Exception
as
e
:
print
(
e
)
return
False
def
get_account_type_value
(
db
:
Session
,
key
):
"""新建类型 查询是否有重复数据"""
return
db
.
query
(
AccountType
)
.
filter
(
AccountType
.
key_value
==
key
)
.
first
()
def
create_type
(
db
:
Session
,
data
):
"""创建新账目类型"""
try
:
db_type
=
AccountType
(
key_name
=
data
.
key_name
,
key_value
=
data
.
key_value
,
type
=
data
.
type
,
create_time
=
datetime
.
now
())
db
.
add
(
db_type
)
db
.
commit
()
db
.
refresh
(
db_type
)
except
Exception
as
e
:
print
(
e
)
return
{}
return
db_type
app/api/account/schemas.py
View file @
3a593bb3
...
...
@@ -59,3 +59,9 @@ class AccountTypeUpdate(BaseModel):
class
AccountTypeList
(
AccountTypeUpdate
):
page
:
int
=
None
size
:
int
=
None
class
CreateType
(
BaseModel
):
key_name
:
str
key_value
:
str
type
:
int
app/api/account/views.py
View file @
3a593bb3
...
...
@@ -85,3 +85,15 @@ def finance_fix(data: schemas.AccountTypeList, db: Session = Depends(get_db)):
if
res
:
return
HttpResultResponse
()
return
HttpResultResponse
(
code
=
422
,
msg
=
'修改失败'
)
@
router
.
post
(
"/create/type"
)
def
create_user
(
data
:
schemas
.
CreateType
,
db
:
Session
=
Depends
(
get_db
)):
"""添加账目类型"""
res_type
=
crud
.
get_account_type_value
(
db
,
data
.
key_value
)
if
res_type
:
return
HttpResultResponse
(
code
=
400
,
msg
=
HttpMessage
.
TYPE_EXIST
)
res
=
crud
.
create_type
(
db
,
data
)
if
not
res
:
return
HttpResultResponse
(
code
=
500
,
msg
=
res
)
return
HttpResultResponse
(
data
=
res
.
id
)
libs/result_format.py
View file @
3a593bb3
...
...
@@ -14,6 +14,7 @@ class HttpMessage(object):
NO_DELETE_ROLE
=
"不能删除已绑定用户的角色!"
ACCOUNT_EXIST
=
"账号已存在"
TYPE_EXIST
=
"类目标识已存在"
DELETE_LOSE
=
'删除失败'
LOSE
=
'操作失败'
...
...
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