package com.diagbot.facade.his;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.dto.RespDTO;
import com.diagbot.dto.his.DoctorHosDTO;
import com.diagbot.entity.his.DoctorHos;
import com.diagbot.service.impl.his.DoctorHosServiceImpl;
import com.diagbot.util.BeanUtil;
import com.diagbot.util.StringUtil;
import com.diagbot.vo.his.DoctorHosVO;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DoctorHosFacade extends DoctorHosServiceImpl {

    public List<DoctorHosDTO> getDoctorInfo(DoctorHosVO doctorHosVO){
        List<DoctorHosDTO> dto= Lists.newArrayList();
        try{
            QueryWrapper<DoctorHos> query = new QueryWrapper<>();
            query.notIn("JOB","护士");
            if(StringUtil.isNotEmpty(doctorHosVO.getKeyString())){
                query.like("USER_ID",doctorHosVO.getKeyString().toUpperCase()).or()
                        .like("NAME",doctorHosVO.getKeyString()).or()
                        .like("DEPT_CODE",doctorHosVO.getKeyString()).or()
                        .like("DEPT_NAME",doctorHosVO.getKeyString());
            }
            List<DoctorHos> list=this.baseMapper.selectList(query);
            dto=BeanUtil.listCopyTo(list,DoctorHosDTO.class);
        }catch (Exception e){
            log.error("获取医生信息异常"+e.getMessage(),new Throwable());
        }
        return dto;
    }
}
