"""
用户素材管理服务使用示例
"""
from backend.services.user_material_service import user_material_service

# 假设有一个用户ID
user_id = 1

# 示例1：上传素材
with open('backend/data/materials/1_0ae46a92003f4081bb53589d3a040569.jpg', 'rb') as f:
    file_bytes = f.read()
    upload_result = user_material_service.upload_material(
        user_id=user_id,
        file_bytes=file_bytes,
        image_type='original',
        original_filename='1_0ae46a92003f4081bb53589d3a040569.jpg',
        stored_path='1_0ae46a92003f4081bb53589d3a040569.jpg',
        image_hash='1_0ae46a92003f4081bb53589d3a040569.jpg'
    )
    print('上传结果:', upload_result)

# 示例2：获取素材列表
list_result = user_material_service.list_materials(
    user_id=user_id,
    material_type='cloth',
    page=1,
    page_size=10
)
print('素材列表:', list_result)

# 示例3：删除素材
if list_result.get('images'):
    material_id = list_result['images'][0]['id']
    delete_result = user_material_service.delete_material(user_id, material_id)
    print('删除结果:', delete_result) 