package com.fs.doctor.controller;

import com.fs.common.BeanCopyUtils;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.doctor.domain.Doctor;
import com.fs.doctor.service.IDoctorService;
import com.fs.doctor.vo.*;
import com.fs.task.vo.TaskFinishAuditReqVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 讲者Controller
 *
 * @author fs
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/doctor/doctor")
public class DoctorController extends BaseController
{
    @Autowired
    private IDoctorService doctorService;

    /**
     * 查询讲者列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:list')")
    @GetMapping("/list")
    public TableDataInfo list(Doctor doctor)
    {
        startPage();
        List<Doctor> list = doctorService.selectDoctorList(doctor);
        List<DoctorVO> doctorVOS = BeanCopyUtils.copyList(list, DoctorVO.class);

        return getDataTable(doctorVOS);
    }

    /**
     * 导出讲者列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:export')")
    @Log(title = "讲者", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Doctor doctor)
    {
        List<Doctor> list = doctorService.selectDoctorList(doctor);
        ExcelUtil<Doctor> util = new ExcelUtil<Doctor>(Doctor.class);
        return util.exportExcel(list, "讲者数据");
    }

    /**
     * 获取讲者详细信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorService.selectDoctorById(id));
    }

    /**
     * 新增讲者
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:add')")
    @Log(title = "讲者", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorVO doctorVO)
    {
       return toAjax( doctorService.add(doctorVO));
    }

    /**
     * 修改讲者
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:edit')")
    @Log(title = "讲者", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Doctor doctor)
    {
        return toAjax(doctorService.updateDoctor(doctor));
    }

    /**
     * 删除讲者
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:remove')")
    @Log(title = "讲者", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorService.deleteDoctorByIds(ids));
    }


        @PreAuthorize("@ss.hasPermi('doctor:doctor:list')")
        @GetMapping("/getDoctorOptionVOList")
        public AjaxResult getDoctorOptionVOList(DoctorOptionReqVO doctorOptionReqVO)
        {
            List<DoctorOptionRespVO> list = doctorService.getDoctorOptionVOList(doctorOptionReqVO);
            return AjaxResult.success(list);
        }


    /**
     * 查询讲者审核页面信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:audit')")
    @GetMapping("/audit/{id}")
    public AjaxResult getAuditInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorService.selectDoctorAuditInfo(id));
    }


    @PreAuthorize("@ss.hasPermi('doctor:doctor:audit')")
    @Log(title = "完成审核处理", businessType = BusinessType.UPDATE)
    @PostMapping("doAudit")
    public void doAudit(@RequestBody DoctorDoAuditReqVO doctorDoAuditReqVO){
        doctorService.doAudit(doctorDoAuditReqVO);
    }



    /**
     * 修改讲者密码
     */
    @PreAuthorize("@ss.hasPermi('doctor:doctor:edit')")
    @Log(title = "讲者-修改密码", businessType = BusinessType.UPDATE)
    @PostMapping("/resetPwd")
    public AjaxResult resetPwd(@RequestBody DoctorResetPwdReqVO req) {
        return toAjax(doctorService.resetPwd(req));
    }


}
