import request from '../utils/request';

/**
 * 获取作品列表
 * @param {number} page - 页码（从1开始）
 * @param {number} pageSize - 每页数量
 * @param {string} category - 分类筛选（可选）
 * @param {string} keyword - 关键词搜索（可选）
 */
export const getWorksList = async (page = 1, pageSize = 20, category = '', keyword = '') => {
  try {
    const params = { page, page_size: pageSize };
    if (category) params.category = category;
    if (keyword) params.keyword = keyword;
    
    const response = await request.get('/works', { params });
    return {
      success: true,
      data: response
    };
  } catch (error) {
    return {
      success: false,
      message: error.message
    };
  }
};

/**
 * 获取作品详情
 * @param {number} workId - 作品ID
 */
export const getWorkDetail = async (workId) => {
  try {
    const response = await request.get(`/works/${workId}`);
    return {
      success: true,
      data: response
    };
  } catch (error) {
    return {
      success: false,
      message: error.message
    };
  }
};
