feat(clients): add clients app basic structure and endpoints

This commit is contained in:
2026-03-11 18:43:11 +08:00
parent 5d1e1cb7cb
commit 7b6b288c41
13 changed files with 286 additions and 0 deletions

34
apps/clients/models.py Normal file
View File

@@ -0,0 +1,34 @@
from django.db import models
from apps.workspaces.models import Workspace
from core.models.base import BaseModel
class Client(BaseModel):
workspace = models.ForeignKey(
Workspace,
on_delete=models.CASCADE,
related_name="clients",
)
name = models.CharField(max_length=255)
notes = models.TextField(blank=True)
class Meta:
db_table = "client"
ordering = ("-updated_at", "-created_at")
indexes = [
models.Index(fields=["id"], name="client_id_idx"),
models.Index(fields=["workspace"], name="client_workspace_idx"),
]
constraints = [
models.UniqueConstraint(
fields=["workspace", "name"],
name="unique_client_name_per_workspace",
condition=models.Q(is_deleted=False),
)
]
def __str__(self):
return self.name