Files
aivideo/backend/app/common/utils/id_gen.py

18 lines
428 B
Python

from datetime import datetime
from random import choices
from string import ascii_uppercase, digits
from uuid import uuid4
def new_public_id(prefix: str) -> str:
return f"{prefix}_{uuid4().hex[:16]}"
def new_order_no(prefix: str) -> str:
return f"{prefix}_{datetime.now():%Y%m%d%H%M%S}{uuid4().hex[:6]}"
def new_invite_code(length: int = 6) -> str:
return "".join(choices(ascii_uppercase + digits, k=length))