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.DoctorSchedule;
import com.openhis.appointmentmanage.service.IDoctorScheduleService;
import com.openhis.web.appointmentmanage.appservice.IDoctorScheduleAppService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService {
    @Resource
    private IDoctorScheduleService doctorScheduleService;


    @Override
    public R<?> getDoctorScheduleList() {
        List<DoctorSchedule> list = doctorScheduleService.list();
        return R.ok(list);
    }

    @Override
    public R<?> addDoctorSchedule(DoctorSchedule doctorSchedule) {
        if (ObjectUtil.isEmpty(doctorSchedule)) {
            return R.fail("医生排班不能为空");
        }
        boolean save = doctorScheduleService.save(doctorSchedule);
        return R.ok(save);
    }

    @Override
    public R<?> removeDoctorSchedule(Integer doctorScheduleId) {
        if (doctorScheduleId == null && ObjectUtil.isEmpty(doctorScheduleId)) {
            return R.fail("排班id不能为空");
        }
        boolean remove = doctorScheduleService.removeById(doctorScheduleId);
        return R.ok(remove);
    }
}
