Commit d30feaa0 authored by xianyang's avatar xianyang

优化业务类目

parent 77d7a69c
......@@ -284,9 +284,9 @@ def update_account_type(db: Session, data):
return False
def get_account_type_value(db: Session, key):
def get_account_type_value(db: Session, key, type):
"""新建类型 查询是否有重复数据"""
return db.query(AccountType).filter(AccountType.key_value == key).first()
return db.query(AccountType).filter(AccountType.key_value == key, AccountType.type == type).first()
def create_type(db: Session, data):
......
......@@ -142,7 +142,7 @@ def finance_fix(data: schemas.AccountTypeList, token=Depends(login_required), db
@router.post("/create/type")
def create_user(data: schemas.CreateType, token=Depends(login_required), db: Session = Depends(get_db)):
"""添加账目类型"""
res_type = crud.get_account_type_value(db, data.key_value)
res_type = crud.get_account_type_value(db, data.key_value, data.type)
if res_type:
return HttpResultResponse(code=400, msg=HttpMessage.TYPE_EXIST)
res = crud.create_type(db, data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment