package com.example.service;

import com.example.bean.Doctor;
import com.example.bean.RespBean;
import com.example.bean.User;
import com.example.bean.Worker;
import com.example.mapper.DoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import javax.print.Doc;
import java.util.List;

@Service
public class DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;

    public Doctor getDoctorById(String userid)
    {
        Doctor doctor = doctorMapper.getDoctorById(userid);
        return doctor;
    }

    public int regDoctor(Doctor doctor)
    {
            int result = doctorMapper.reg(doctor);
            boolean b = result == 1;
            if(b)
                return 0;//返回0表示注册成功
            else
                return 2;//返回2表示注册失败
    }

    public int updateQualification(byte[] qualification,String userid)
    {
        int i = doctorMapper.updateQualification(qualification, userid);
        return i;
    }

    public int updateDoctorEnabled(boolean enabled,String userid)//更新医生的enabled属性
    {
        return doctorMapper.updateDoctorEnabled(enabled,userid);//1表示更新成功，其他表示失败
    }

    public int deleteDoctor(String userid)//根据id删除医生
    {
        return doctorMapper.deleteUserByUserid(userid);
    }

    public int updateDoctor(Doctor doctor)//更新医生信息
    {
        return doctorMapper.updateDoctor(doctor);
    }

    public List<User> getAllMyUsers(String id)
    {
        return doctorMapper.getAllMyUsers(id);
    }

    public List<Doctor> selectUnabled()
    {
        return doctorMapper.selectUnabledDoctor();
    }

}
