import { httpApp } from "@/plugins/axiosApp";
import { RootOrg, ServerPageResponse } from "@/types";

/** 学校分页查询 */
export function getRootOrgList(params: {
  code?: string;
  name?: string;
  enable?: boolean;
  pageNo?: number;
  pageSize?: number;
}) {
  return httpApp.post<any, ServerPageResponse<RootOrg>>(
    "/api/ess/root/org/page",
    params
  );
}

/** 更新学校 */
export function updateRootOrg(params: {
  // code: string;
  // name: string;
  // enable: boolean;
  id:number;
  domainName: string;
}) {
  return httpApp.post("/api/ess/root/org/update", params);
}

/** 查询学校所有属性 */
export function getRootOrgSettings(orgId: number) {
  return httpApp.post(`/api/ess/root/org/property/all/${orgId}`);
}

/** 查询机构单个属性 */
export function getRootOrgSettingsOfKey(orgId: number, key: string) {
  return httpApp.post(`/api/ess/root/org/property/${orgId}/${key}`);
}

/** 保存机构属性 */
export function saveOrgSetting(orgId: number, properties: any) {
  return httpApp.post(`/api/ess/root/org/property/save`, { orgId, properties });
}

/** 同步学校 */
export function syncRootOrg() {
  return httpApp.post(`/api/ess/root/org/sync`);
}
