feat: deal tags
This commit is contained in:
81
routers/crm/v1/deal_tag.py
Normal file
81
routers/crm/v1/deal_tag.py
Normal file
@ -0,0 +1,81 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from backend.dependecies import SessionDependency
|
||||
from schemas.deal_tag import *
|
||||
from services import DealTagService
|
||||
|
||||
router = APIRouter(tags=["deal-tag"])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{projectId}",
|
||||
response_model=GetDealTagsResponse,
|
||||
operation_id="get_deal_tags",
|
||||
)
|
||||
async def get_deal_tags(
|
||||
session: SessionDependency,
|
||||
projectId: int = Path(alias="projectId"),
|
||||
):
|
||||
return await DealTagService(session).get_all(projectId)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/",
|
||||
operation_id="create_deal_tag",
|
||||
response_model=CreateDealTagResponse,
|
||||
)
|
||||
async def create_deal_tag(
|
||||
request: CreateDealTagRequest,
|
||||
session: SessionDependency,
|
||||
):
|
||||
return await DealTagService(session).create(request)
|
||||
|
||||
|
||||
@router.patch(
|
||||
"/{pk}",
|
||||
operation_id="update_deal_tag",
|
||||
response_model=UpdateDealTagResponse,
|
||||
)
|
||||
async def update_deal_tag(
|
||||
request: UpdateDealTagRequest,
|
||||
session: SessionDependency,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await DealTagService(session).update(pk, request)
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/{pk}",
|
||||
response_model=DeleteDealTagResponse,
|
||||
operation_id="delete_deal_tag",
|
||||
)
|
||||
async def delete_deal_tag(
|
||||
session: SessionDependency,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await DealTagService(session).delete(pk)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/switch",
|
||||
response_model=SwitchDealTagResponse,
|
||||
operation_id="switch_deal_tag",
|
||||
)
|
||||
async def switch_deal_tag(
|
||||
session: SessionDependency,
|
||||
request: SwitchDealTagRequest,
|
||||
):
|
||||
return await DealTagService(session).switch_tag(request)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/colors",
|
||||
response_model=GetTagColorsResponse,
|
||||
operation_id="get_deal_tag_colors",
|
||||
)
|
||||
async def get_deal_tag_colors(
|
||||
session: SessionDependency,
|
||||
):
|
||||
return await DealTagService(session).get_tag_colors()
|
||||
Reference in New Issue
Block a user