package com.ruoyi.framework.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.system.domain.Doctors;
import com.ruoyi.framework.system.service.IDoctorsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/system/Doctors")
public class DoctorsController extends BaseController
{
    @Autowired
    private IDoctorsService doctorsService;

    /**
     * 查询医生信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:list')")
    @GetMapping("/list")
    public TableDataInfo list(Doctors doctors)
    {
        startPage();
        List<Doctors> list = doctorsService.selectDoctorsList(doctors);
        return getDataTable(list);
    }

    /**
     * 导出医生信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:export')")
    @Log(title = "医生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Doctors doctors)
    {
        List<Doctors> list = doctorsService.selectDoctorsList(doctors);
        ExcelUtil<Doctors> util = new ExcelUtil<Doctors>(Doctors.class);
        util.exportExcel(response, list, "医生信息数据");
    }

    /**
     * 获取医生信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:query')")
    @GetMapping(value = "/{DoctorID}")
    public AjaxResult getInfo(@PathVariable("DoctorID") Long DoctorID)
    {
        return success(doctorsService.selectDoctorsByDoctorID(DoctorID));
    }

    /**
     * 新增医生信息
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:add')")
    @Log(title = "医生信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Doctors doctors)
    {
        return toAjax(doctorsService.insertDoctors(doctors));
    }

    /**
     * 修改医生信息
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:edit')")
    @Log(title = "医生信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Doctors doctors)
    {
        return toAjax(doctorsService.updateDoctors(doctors));
    }

    /**
     * 删除医生信息
     */
    @PreAuthorize("@ss.hasPermi('system:Doctors:remove')")
    @Log(title = "医生信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{DoctorIDs}")
    public AjaxResult remove(@PathVariable Long[] DoctorIDs)
    {
        return toAjax(doctorsService.deleteDoctorsByDoctorIDs(DoctorIDs));
    }
}
