import {Component} from '@angular/core';
import {ActivatedRoute} from "@angular/router";

import * as Parse from "parse"

(Parse as any).serverURL = "http://web2023.fmode.cn:23000/parse"
Parse.initialize("dev")

@Component({
  selector: 'app-companydetail',
  templateUrl: './companydetail.component.html',
  styleUrls: ['./companydetail.component.scss']
})
export class CompanydetailComponent {
  company: any = {}

  constructor(private route: ActivatedRoute) {
    this.route.queryParams.subscribe(params => {
      console.log(params["id"])
      this.getCompanyById(params["id"])
    })
  }

  async getCompanyById(id: any) {
    console.log(id)
    // 创建 Parse.Query 对象
    const query = new Parse.Query("LjCompany");

    try {
      // 使用 get 方法查询对象
      query.equalTo('comno', '000000001');
      const company = await query.find();
      this.company = company[0].attributes
      console.log(this.company)
    } catch (error) {
      console.error("Error retrieving company:", error);
      throw error;
    }
  }


}
