Skip to content

Commit

Permalink
Merge pull request #886 from longguikeji/feature-276
Browse files Browse the repository at this point in the history
更正错误的返回值结构
  • Loading branch information
guancyxx authored May 31, 2022
2 parents b216221 + 4edcecd commit ace4209
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions api/v1/views/account_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def create_account_life(request, tenant_id: str, data: AccountLifeCreateIn):
data=config,
)
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.put(
Expand All @@ -121,7 +121,7 @@ def update_account_life(request, tenant_id: str, id: str, data: AccountLifeUpdat
data=config,
)
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete(
Expand All @@ -143,4 +143,4 @@ def delete_account_life(request, tenant_id: str, id: str):
)
)
config.delete()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}
4 changes: 2 additions & 2 deletions api/v1/views/approve_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_approve_system(request, tenant_id: str, data: ApproveSystemCreateIn):
data=setting,
)
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.put(
Expand All @@ -116,7 +116,7 @@ def update_approve_system(
data=setting,
)
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete(
Expand Down
6 changes: 3 additions & 3 deletions api/v1/views/auth_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_auth_factor(request, tenant_id: str, data: AuthFactorCreateIn):
config.name = data.dict()["name"]
config.type = data.type
config.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.post("/tenant/{tenant_id}/auth_factors/{id}/", response=AuthFactorUpdateOut, tags=["认证因素"], auth=None)
Expand All @@ -78,7 +78,7 @@ def update_auth_factor(request, tenant_id: str, id: str, data: AuthFactorUpdateI
for attr, value in data.dict().items():
setattr(config, attr, value)
config.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete("/tenant/{tenant_id}/auth_factors/{id}/", response=AuthFactorDeleteOut, tags=["认证因素"], auth=None)
Expand All @@ -90,4 +90,4 @@ def delete_auth_factor(request, tenant_id: str, id: str):
tenant__id=tenant_id, id=id
)
config.delete()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}
6 changes: 3 additions & 3 deletions api/v1/views/auth_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_auth_rule(request, tenant_id: str, data: AuthRuleCreateIn):
config.name = data.dict()["name"]
config.type = data.type
config.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.post("/tenant/{tenant_id}/auth_rules/{id}/", response=AuthRuleUpdateOut, tags=["认证规则"], auth=None)
Expand All @@ -80,7 +80,7 @@ def update_auth_rule(request, tenant_id: str, id: str, data: AuthRuleUpdateIn):
for attr, value in data.dict().items():
setattr(config, attr, value)
config.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete("/tenant/{tenant_id}/auth_rules/{id}/", response=AuthRuleDeleteOut, tags=["认证规则"], auth=None)
Expand All @@ -92,4 +92,4 @@ def delete_auth_rule(request, tenant_id: str, id: str):
tenant__id=tenant_id, id=id
)
config.delete()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}
6 changes: 3 additions & 3 deletions api/v1/views/auto_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_auto_auth(request, tenant_id: str, data: AutoAuthCreateIn):
)
)

return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.put(
Expand All @@ -124,7 +124,7 @@ def update_auto_auth(request, tenant_id: str, id: str, data: AutoAuthUpdateIn):
data=setting,
)
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete(
Expand All @@ -146,4 +146,4 @@ def delete_auto_auth(request, tenant_id: str, id: str):
)
)
setting.kill()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}
6 changes: 3 additions & 3 deletions api/v1/views/scim_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def create_scim_sync(request, tenant_id: str, data: ScimSyncCreateIn):
)
if data.config.mode == "client":
update_or_create_periodic_task(config)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.put(
Expand All @@ -148,7 +148,7 @@ def update_scim_sync(request, tenant_id: str, id: str, data: ScimSyncUpdateIn):
if data.config.mode == "client":
update_or_create_periodic_task(config)

return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete("/tenant/{tenant_id}/scim_syncs/{id}/", tags=[_("用户数据同步配置")], auth=None)
Expand All @@ -159,7 +159,7 @@ def delete_scim_sync(request, tenant_id: str, id: str):
if config.config["mode"] == "client":
delete_periodic_task(config)
config.delete()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


class ScimServerOut(ModelSchema):
Expand Down
6 changes: 3 additions & 3 deletions api/v1/views/third_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def create_third_auth(request, tenant_id: str, data: ThirdAuthCreateIn):
extension_setting = extension.update_or_create_settings(
request.tenant, data.config.dict(), True, False
)
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.put(
Expand All @@ -97,7 +97,7 @@ def update_third_auth(request, tenant_id: str, id: str, data: ThirdAuthUpdateIn)
setting = TenantExtension.valid_objects.get(tenant__id=tenant_id, id=id)
setting.settings = data.config.dict()
setting.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.delete(
Expand All @@ -112,4 +112,4 @@ def delete_third_auth(request, tenant_id: str, id: str):

setting = TenantExtension.valid_objects.get(tenant__id=tenant_id, id=id)
setting.kill()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}
16 changes: 8 additions & 8 deletions api/v1/views/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def get_webhook_history(request, tenant_id: str, webhook_id: str, id: str):
tenant = request.tenant
webhook = Webhook.valid_objects.filter(tenant=tenant, id=webhook_id).first()
if not webhook:
return {"data": {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}
history = WebhookTriggerHistory.valid_objects.filter(webhook=webhook, id=id).first()
if not history:
return {"data": {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}
return {"data": history}


Expand All @@ -174,12 +174,12 @@ def delete_webhook_history(request, tenant_id: str, webhook_id: str, id: str):
tenant = request.tenant
webhook = Webhook.valid_objects.filter(tenant=tenant, id=webhook_id).first()
if not webhook:
return {"data": {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}
history = WebhookTriggerHistory.valid_objects.filter(webhook=webhook, id=id).first()
if not history:
return {"data": {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}
history.delete()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}


@api.get(
Expand All @@ -193,10 +193,10 @@ def retry_webhook_history(request, tenant_id: str, webhook_id: str, id: str):
tenant = request.tenant
webhook = Webhook.valid_objects.filter(tenant=tenant, id=webhook_id).first()
if not webhook:
return {"data": {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_NOT_EXISTS.value}
history = WebhookTriggerHistory.valid_objects.filter(webhook=webhook, id=id).first()
if not history:
return {"data": {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}}
return {'error': ErrorCode.WEBHOOK_HISTORY_NOT_EXISTS.value}

webhook = history.webhook
url = webhook.url
Expand Down Expand Up @@ -225,4 +225,4 @@ def retry_webhook_history(request, tenant_id: str, webhook_id: str, id: str):
}
)
history.save()
return {"data": {'error': ErrorCode.OK.value}}
return {'error': ErrorCode.OK.value}

0 comments on commit ace4209

Please sign in to comment.