

class UserPydantic(BaseModel):

    username: str = Field(..., alias='user.username')
    account_balance: float = Field(..., alias='user.account_balance')
    preferred_category_id: Optional[int] = Field(None, alias='user.preferred_category_id')
    last_ordered_product_id: Optional[int] = Field(None, alias='user.last_ordered_product_id')
    supplier_rating_id: Optional[int] = Field(None, alias='user.supplier_rating_id')
    other_rating_id: Optional[int] = Field(None, alias='product.supplier_rating_id')
    id: int = Field(..., alias='user.id')

    class Config:
        validate_by_name = True
        use_enum_values = True
    
    def model_dump(self, *args, **kwargs):
        data = super().model_dump(*args, **kwargs)
        return {self.__class__.model_fields[field].alias: value for field, value in data.items()}
