import request from "../request";

const platform = sessionStorage.getItem("platform") || "classroom";
const api = platform == "classroom" ? "/edu-app" : "/api-backend";
/**
 * 即时通讯 - 群组列表
 */
export const imGroupPage = (params?: object) => {
  return request.post(api + "/imGroup/page", {
    data: params,
  });
};

/**
 * 即时通讯 - 好友列表
 */
export const imUserFriendPage = (params?: object) => {
  return request.post(api + "/imUserFriend/page", {
    data: params,
  });
};

/**
 * 即时通讯 - 转让群组
 */
export const imGroupChangeGroupOwner = (params?: object) => {
  return request.post(api + "/imGroup/changeGroupOwner", {
    data: params,
  });
};

/**
 * 即时通讯 - 群公告列表
 */
export const imGroupNoticePage = (params?: object) => {
  return request.post(api + "/imGroupNotice/page", {
    data: params,
  });
};

/**
 * 即时通讯 - 新增公告
 */
export const imGroupNoticeSave = (params?: object) => {
  return request.post(api + "/imGroupNotice/save", {
    data: params,
  });
};

/**
 * 即时通讯 - 修改群公告
 */
export const imGroupNoticeUpdate = (params?: object) => {
  return request.post(api + "/imGroupNotice/update", {
    data: params,
  });
};

/**
 * 即时通讯 - 详情
 */
export const imGroupDetail = (params?: any) => {
  return request.get(api + "/imGroup/detail/" + params.id);
};

/**
 * 即时通讯 - 群成员
 */
export const imGroupMemberPage = (params?: any) => {
  return request.post(api + "/imGroupMember/page", {
    data: params,
  });
};

/**
 * 即时通讯 - 用户详情
 */
export const imGroupMemberUserDetail = (params?: any) => {
  return request.post(api + "/imGroupMember/userDetail", {
    data: params,
  });
};

/**
 * 即时通讯 - 退出群聊
 */
export const imGroupQuit = (params?: any) => {
  return request.post(api + "/imGroup/quit/" + params.id, {
    data: params,
  });
};

/**
 * 即时通讯 - 全体禁言-解除禁言
 */
export const imGroupMuteAll = (params?: any) => {
  return request.post(api + "/imGroup/muteAll", {
    data: params,
  });
};

/**
 * 即时通讯 - 批量IM新增
 */
export const imGroupMemberSaveImAll = (params?: any) => {
  return request.post(api + "/imGroupMember/saveImAll", {
    data: params,
  });
};

/**
 * 即时通讯 - 解散群聊
 */
export const imGroupDismiss = (params?: any) => {
  return request.post(api + "/imGroup/dismiss/" + params.id, {
    data: params,
  });
};
