import { baseHttpUtils } from "@/utils/http/baseHttpUtils";
import { model_pre } from "./preTypes";
class FileController {
  static http = new baseHttpUtils();

  /**
   * 根据模型id 获取模型文件夹及文件名
   * @param params
   * @returns
   */
  static async getFileNameById(params) {
    return await this.http.postRequest(
      model_pre + "/model-folder/get-name",
      params
    );
  }
  /**
   * 根据条件查询统计数量
   * @param params
   * @returns
   */
  static async countModel(params) {
    return await this.http.postRequest(model_pre + "/model-file/count", params);
  }
  /**
   * 楼层与平面图绑定
   * @param params
   * @returns
   */
  static async bindFloorModel(params) {
    return await this.http.postRequest(model_pre + "/model-file/bind", params);
  }
  /**
   * 查询模型文件夹下的所有模型文件
   * @param params
   * @returns
   */
  static async queryFloorList(data) {
    let Filters = `FolderId='${data.FolderId}'`;
    if (data.FloorName) {
      Filters = `FolderId='${data.FolderId}';FloorName='${data.FloorName}';ProjectId='${data.ProjectId}'`;
    }
    if (data.Status) {
      Filters += `;Status in [${data.Status}]`;
    }
    let params = {
      Filters: Filters,
      PageNumber: 1,
      PageSize: 500,
    };
    return await this.http.postRequest(
      model_pre + "/model-file/query-list",
      params
    );
  }
  /**
   * 查询模型文件夹
   * @param params
   * @returns
   */
  static async queryModel(Name) {
    let data = null;
    if (Name) {
      // 单个查询
      data = {
        Filters: `Name='${Name}'`,
        Orders: "Name asc",
      };
    } else {
      // 多个查询
      data = {
        Orders: "Name asc",
      };
    }
    return await this.http.postRequest(model_pre + "/model-folder/query", data);
  }
}

export default FileController;
