package com.openhis.web.appointmentmanage.appservice.impl;

import cn.hutool.core.util.ObjectUtil;
import com.core.common.core.domain.R;
import com.openhis.appointmentmanage.domain.SchedulePool;
import com.openhis.appointmentmanage.service.ISchedulePoolService;
import com.openhis.web.appointmentmanage.appservice.ISchedulePoolAppService;
import com.openhis.web.appointmentmanage.dto.SchedulePoolDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SchedulePoolAppServiceImpl implements ISchedulePoolAppService {

    @Resource
    private ISchedulePoolService schedulePoolService;

    @Override
    public R<?> addSchedulePool(SchedulePoolDto schedulePoolDto) {
        //1.数据检验
        if(ObjectUtil.isNull(schedulePoolDto)){
            return R.fail("号源不能为空");
        }
        //2.封装实体
        SchedulePool schedulePool = new SchedulePool();
        schedulePool.setHospitalId(schedulePoolDto.getHospitalId());
        schedulePool.setDeptId(schedulePoolDto.getDeptId());
        schedulePool.setDoctorId(schedulePoolDto.getDoctorId());
        schedulePool.setDoctorName(schedulePoolDto.getDoctorName());
        schedulePool.setScheduleDate(schedulePoolDto.getScheduleDate());
        schedulePool.setShift(schedulePoolDto.getShift());
        schedulePool.setStartTime(schedulePoolDto.getStartTime());
        schedulePool.setEndTime(schedulePoolDto.getEndTime());

        schedulePool.setRegType(schedulePoolDto.getRegType());
        schedulePool.setFee(schedulePoolDto.getFee());
        //3.保存
        boolean save = schedulePoolService.save(schedulePool);
        return R.ok(save);
    }
}
