wip:(重构接口实现方式)

This commit is contained in:
zhengxinonly
2022-05-09 03:30:41 +08:00
parent 8760f21b03
commit 82de7b0273
11 changed files with 71 additions and 106 deletions
+5
View File
@@ -0,0 +1,5 @@
def register_api(view, endpoint, url, pk='id', pk_type='int', app=None):
view_func = view.as_view(endpoint)
app.add_url_rule(url, defaults={pk: None}, view_func=view_func, methods=['GET', ])
app.add_url_rule(url, view_func=view_func, methods=['POST', ])
app.add_url_rule(f'{url}<{pk_type}:{pk}>', view_func=view_func, methods=['GET', 'PUT', 'DELETE'])