import request from "@/utils/request";

/*************************************************
 ****************** 宝贝相关接口 ******************
 *************************************************/

/**
 * 获取宝贝列表
 * @returns {Promise}
 */
export function getBabyList() {
  return request({
    url: '/backend/babys/list',
    method: 'get'
  });
}

/**
 * 获取宝贝详情
 * @param {number} id 宝贝ID
 * @returns {Promise}
 */
export function getBabyDetail(id) {
  return request({
    url: `/backend/babys/${id}`,
    method: "get",
  });
}

/**
 * 创建宝贝数据
 * @param {Object} data 宝贝数据
 * @returns {Promise}
 */
export function createBaby(data) {
  return request({
    url: "/backend/babys",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

// 更新宝贝信息
export function editBaby(id, data) {
  return request({
    url: `/backend/baby/update/${id}`,
    method: 'post',
    data: data
  });
}

/**
 * 删除宝贝数据
 * @param {number} id 宝贝ID
 * @returns {Promise}
 */
export function deleteBaby(id) {
  return request({
    url: `/backend/babys/${id}`,
    method: "delete",
  });
}

/**
 * 绑定父母
 * @param {number} id 宝贝ID
 * @param {Object} data 绑定数据
 * @returns {Promise}
 */
export function bindParent(id, data) {
  return request({
    url: `/backend/babys/bindparents/${id}`,
    method: "post",
    data: data,
  });
}

/**
 * 获取父母
 * @param {number} id 宝贝ID
 * @returns {Promise}
 */
export function getParents(id) {
  return request({
    url: `/backend/babys/getParents/${id}`,
    method: "get",
  });
}

/*************************************************
 ****************** 用户相关接口 ******************
 *************************************************/

/**
 * 获取用户列表
 * @returns {Promise}
 */
export function getUserList() {
  return request({
    url: "/backend/babyhealthUser/list",
    method: "get",
  });
}

/**
 * 获取用户详情
 * @param {number} id 用户ID
 * @returns {Promise}
 */
export function getUserDetail(id) {
  return request({
    url: `/backend/babyhealthUser/detail/${id}`,
    method: "get",
  });
}

/**
 * 创建用户数据
 * @param {Object} data 用户数据
 * @returns {Promise}
 */
export function createUser(data) {
  return request({
    url: "/backend/babyhealthUser/create",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

/**
 * 更新用户数据
 * @param {number} id 用户ID
 * @param {Object} data 更新的数据
 * @returns {Promise}
 */
export function updateUser(id, data) {
  return request({
    url: `/backend/babyhealthUser/update/${id}`,
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

/**
 * 删除用户数据
 * @param {number} id 用户ID
 * @returns {Promise}
 */
export function deleteUser(id) {
  return request({
    url: `/backend/babyhealthUser/delete/${id}`,
    method: "delete",
  });
}


/*************************************************
 ****************** 仪表盘相关接口 ******************
 *************************************************/

/**
 * dashborad总体输出
 * @returns {Promise}
 */
export function getDashborad() {
  return request({
    url: "/backend/babyhealthDashborad/dashborad",
    method: "get",
  });
}