import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { AppProduct } from './model';

const BASE = '/app/product';

/** 分页查询我的应用 */
export async function pageMyApps(params?: { current?: number; size?: number }) {
  const res = await request.get<ApiResult<PageResult<AppProduct>>>(BASE + '/my/page', { params });
  if (res.code === 0) return res.data;
  return Promise.reject(new Error(res.message));
}

/** 获取我参与的应用列表 */
export async function listJoinedApps(params?: { page?: number; limit?: number }) {
  const res = await request.get<ApiResult<PageResult<AppProduct>>>(BASE + '/page', { params });
  if (res.code === 0) return res.data;
  return Promise.reject(new Error(res.message));
}
