1.调整返回的code码
This commit is contained in:
parent
5384a20004
commit
100d53a03b
@ -1131,7 +1131,7 @@ async def api_list(
|
||||
if i['path_name'] != 'root':
|
||||
i['_id'] = str(i['_id'])
|
||||
res.append(i)
|
||||
return schemas.Msg(code=0, msg='ok', data=res)
|
||||
return schemas.Msg(code=200, msg='ok', data=res)
|
||||
|
||||
|
||||
@router.post("/del_api_module")
|
||||
@ -1147,7 +1147,7 @@ async def add_policy(
|
||||
if data_in.url == res['api_list'][i]:
|
||||
res['state'][i] = False
|
||||
await crud.api_module.update_one_module(db, res)
|
||||
return schemas.Msg(code=0, msg='修改成功', data='')
|
||||
return schemas.Msg(code=200, msg='修改成功', data='')
|
||||
|
||||
|
||||
@router.post("/add_api_module")
|
||||
@ -1163,14 +1163,14 @@ async def add_policy(
|
||||
if data_in.url == res['api_list'][i]:
|
||||
res['state'][i] = True
|
||||
await crud.api_module.update_one_module(db, res)
|
||||
return schemas.Msg(code=0, msg='修改成功', data='')
|
||||
return schemas.Msg(code=200, msg='修改成功', data='')
|
||||
|
||||
|
||||
@router.get("/api_module")
|
||||
async def domain_list(
|
||||
request: Request,
|
||||
db: AsyncIOMotorDatabase = Depends(get_database),
|
||||
current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
# current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
) -> schemas.Msg:
|
||||
"""
|
||||
角色管理创建角色时显示的各个模块
|
||||
@ -1183,7 +1183,7 @@ async def domain_list(
|
||||
data.append(i['auth_id'])
|
||||
data.append(i['path_name'])
|
||||
api_module.append(data)
|
||||
return schemas.Msg(code=0, msg='ok', data=api_module)
|
||||
return schemas.Msg(code=200, msg='ok', data=api_module)
|
||||
|
||||
|
||||
@router.post("/add_api")
|
||||
@ -1191,19 +1191,19 @@ async def add_api(
|
||||
request: Request,
|
||||
data_in: schemas.AddApi,
|
||||
db: AsyncIOMotorDatabase = Depends(get_database),
|
||||
current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
# current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
) -> schemas.Msg:
|
||||
"""
|
||||
添加api
|
||||
'在api_module'添加api
|
||||
"""
|
||||
res = await crud.api_module.get_api_module(db)
|
||||
for i in res:
|
||||
for i in res: # 判断路由是否存在
|
||||
if data_in.path in i['api_list']:
|
||||
return schemas.Msg(code=0, msg='该路由已存在', data='')
|
||||
return schemas.Msg(code=200, msg='该路由已存在', data='')
|
||||
path_list = []
|
||||
for i in res:
|
||||
path_list.append(i['path_name'])
|
||||
if data_in.name in path_list:
|
||||
if data_in.name in path_list: # 在原有的基础上添加路由
|
||||
for i in res:
|
||||
if data_in.name == i['path_name']:
|
||||
i['api_list'].append(data_in.path)
|
||||
@ -1214,8 +1214,8 @@ async def add_api(
|
||||
api_list=i['api_list'],
|
||||
api_name=i['api_name'],
|
||||
state=i['state']))
|
||||
return schemas.Msg(code=0, msg='ok', data='路由添加成功!')
|
||||
else:
|
||||
return schemas.Msg(code=200, msg='ok', data='路由添加成功!')
|
||||
else: # 另外添加新的权限模块
|
||||
auth_list = []
|
||||
for i in res:
|
||||
auth_list.append(i['auth_id'])
|
||||
@ -1224,4 +1224,4 @@ async def add_api(
|
||||
await crud.api_module.insert_quanxian(db, schemas.Url_module(auth_id=auth_id, path_name=data_in.name,
|
||||
api_list=[data_in.path],
|
||||
api_name=[data_in.desc], state=[True]))
|
||||
return schemas.Msg(code=0, msg='ok', data='路由添加成功!')
|
||||
return schemas.Msg(code=200, msg='ok', data='路由添加成功!')
|
||||
|
Loading…
Reference in New Issue
Block a user