import { Component, OnInit } from '@angular/core';
import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';

@Component({
  selector: 'app-page-user-inquery',
  templateUrl: './page-user-inquery.component.html',
  styleUrls: ['./page-user-inquery.component.scss'],
  standalone: true,
})
export class PageUserInqueryComponent  implements OnInit {
  currentUser:CloudUser;
  constructor(
  ) {
    this.currentUser = new CloudUser();
   }
   departName:string = ''
   objectId: string = ''
  ngOnInit() {}
  async load(){
    let depart = new CloudQuery('Department');
    depart.equalTo("name", this.departName)
    let object = await depart.find()
    if (!object){
      console.log("科室名不存在")
      return 
    }
    console.log('object',object)
    this.currentUser = new CloudUser();
    console.log('currentUser',this.currentUser)
    let doctor = new CloudObject('Doctor1');
    doctor.set({
      avatar: 'https://app.fmode.cn/dev/jxnu/202226701019/doctor7.png',
    name: '张三',
    title: '主任医师',
    depart: {
      __type:"Pointer",
      className:"Department",
      objectId:object[0].id
    },
    hospital: '首都医科大学附属北京友谊..',
    hospitalLevel: '三甲',
    hospitalType: '百强医院',
    expertise: '擅长：结肠息肉和息肉病、胃息肉、幽门螺杆菌感染、慢性胃炎、胃食管反流、慢性萎缩性胃炎、糜烂性胃炎...',
    rating: 5.0,
    consultations: '1.1万',
    recommendations: 100,
    prices: {
      text: 100,
      voice: 150,
      video: 300
    },
    tags: ['百强医院', '可开处方', '从业24年', '擅长消化系统疾病', '可开处方'],
    isVerified: true,
    isExpert: true,
    user: {
      __type:"Pointer",
      className:"User",
      objectId:this.objectId
    }
    })
    doctor.save()
    console.log('doctor',doctor)
  }
}
