package com.fs.app.controller;

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.DoctorLevelApply;
import com.fs.doctor.service.IDoctorLevelApplyService;
import com.fs.doctor.vo.DoctorApplyAuditReqVO;
import com.fs.doctor.vo.DoctorLevelApplyVO;
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
 */
@RestController
@RequestMapping("/doctor/apply")
public class DoctorLevelApplyController extends BaseController
{
    @Autowired
    private IDoctorLevelApplyService doctorLevelApplyService;

    /**
     * 查询讲者定级申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DoctorLevelApply doctorLevelApply)
    {
        startPage();
        List<DoctorLevelApply> list = doctorLevelApplyService.selectDoctorLevelApplyList(doctorLevelApply);
        return getDataTable(list);
    }

    /**
     * 导出讲者定级申请列表
     */
    @GetMapping("/export")
    public AjaxResult export(DoctorLevelApply doctorLevelApply)
    {
        List<DoctorLevelApply> list = doctorLevelApplyService.selectDoctorLevelApplyList(doctorLevelApply);
        ExcelUtil<DoctorLevelApply> util = new ExcelUtil<DoctorLevelApply>(DoctorLevelApply.class);
        return util.exportExcel(list, "讲者定级申请数据");
    }

    /**
     * 获取讲者定级申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorLevelApplyService.selectDoctorLevelApplyById(id));
    }

    /**
     * 新增讲者定级申请
     */
    @PostMapping
    public AjaxResult add(@RequestBody DoctorLevelApplyVO doctorLevelApplyVO)
    {
        return toAjax(doctorLevelApplyService.insertDoctorLevelApply(doctorLevelApplyVO));
    }

    /**
     * 修改讲者定级申请
     */
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorLevelApplyVO doctorLevelApplyVO)
    {
        return toAjax(doctorLevelApplyService.updateDoctorLevelApply(doctorLevelApplyVO));
    }

    /**
     * 讲者定级申请详情
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorLevelApplyService.deleteDoctorLevelApplyByIds(ids));
    }
    @GetMapping(value = "/getDoctorApplyDetailInfoById")
    public AjaxResult getDoctorApplyDetailInfoById(@RequestParam("id") Long id){

        return AjaxResult.success(doctorLevelApplyService.getDoctorApplyDetailInfoById(id));
    }


    @PostMapping(value = "/doAudit")
    public void doAudit(@RequestBody DoctorApplyAuditReqVO doctorApplyAuditReqVO){
        doctorLevelApplyService.doAudit(doctorApplyAuditReqVO);
    }
}
