File size: 1,056 Bytes
8450c71 68ce4db 8450c71 68ce4db 8450c71 68ce4db 8450c71 68ce4db 8450c71 68ce4db f4dfdc4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from fastapi import APIRouter, status
from .Schemas import createPost, editPost, getPost
from .Model import Post
post_router = APIRouter(tags=["Posts"])
@post_router.post("/post/create")
async def create_post(post: createPost):
data = await Post.objects.create(**post.dict())
return {"code": 200, "message": "success", "payload": data.__dict__}
@post_router.post("/post/update")
async def create_post(post: editPost):
temp = await Post.objects.get(id=post.id)
data = await temp.update(recommendations=post.recommendations, content=post.content)
# data=await Post.objects.update(**post.dict())
return {"code": 200, "message": "success", "payload": temp.__dict__}
@post_router.post("/post/get")
async def create_post(post: getPost):
data = await Post.objects.get(id=post.id)
return {"code": 200, "message": "success", "payload": data.__dict__}
@post_router.post("/post/delete_all")
async def create_post():
data = await Post.objects.delete()
return {"code": 200, "message": "success", "payload": data.__dict__} |