from pydantic import BaseModel
from typing import Optional, List, Dict, Any
from datetime import datetime

class CustomerBase(BaseModel):
    customer_id: str
    customer_name: Optional[str] = None
    nick_name: Optional[str] = None
    head_url: Optional[str] = None
    gender: Optional[int] = None
    customer_remark: Optional[str] = None
    customer_desc: Optional[str] = None
    mobiles: Optional[List[str]] = None
    labels: Optional[List[Dict[str, Any]]] = None
    source_type: Optional[int] = None
    apply_mode: Optional[int] = None
    source_tips: Optional[str] = None
    source_room_id: Optional[str] = None
    source_room_name: Optional[str] = None
    source_room_image: Optional[str] = None
    follow_member_vid: str
    follow_member_name: Optional[str] = None
    follow_member_mobile: Optional[str] = None
    follow_member_dept: Optional[str] = None
    follow_member_avatar: Optional[str] = None
    create_time: Optional[int] = None
    update_time: Optional[int] = None
    tag_time: Optional[int] = None
    add_time: Optional[int] = None
    friend_flag: Optional[int] = None
    relation_flag: Optional[int] = None
    cus_channel: Optional[str] = None
    seq: Optional[str] = None
    kh_type: Optional[int] = None
    room_count: Optional[int] = 0
    user_count: Optional[int] = 0
    data_version: Optional[str] = None

class CustomerCreate(CustomerBase):
    pass

class CustomerUpdate(BaseModel):
    customer_name: Optional[str] = None
    customer_remark: Optional[str] = None
    customer_desc: Optional[str] = None
    mobiles: Optional[List[str]] = None
    labels: Optional[List[Dict[str, Any]]] = None
    follow_member_name: Optional[str] = None
    follow_member_mobile: Optional[str] = None
    follow_member_dept: Optional[str] = None
    source_tips: Optional[str] = None
    cus_channel: Optional[str] = None

class Customer(CustomerBase):
    id: int
    data_source: Optional[str] = None
    last_updated_from: Optional[str] = None
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True