package com.fs.doc.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.doc.domain.DocOrder;
import com.fs.doc.service.IDocOrderService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 问医生Controller
 * 
 * @author fs
 * @date 2023-01-09
 */
@RestController
@RequestMapping("/doc/docOrder")
public class DocOrderController extends BaseController
{
    @Autowired
    private IDocOrderService docOrderService;

    /**
     * 查询问医生列表
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocOrder docOrder)
    {
        startPage();
        List<DocOrder> list = docOrderService.selectDocOrderList(docOrder);
        return getDataTable(list);
    }

    /**
     * 导出问医生列表
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:export')")
    @Log(title = "问医生", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DocOrder docOrder)
    {
        List<DocOrder> list = docOrderService.selectDocOrderList(docOrder);
        ExcelUtil<DocOrder> util = new ExcelUtil<DocOrder>(DocOrder.class);
        return util.exportExcel(list, "docOrder");
    }

    /**
     * 获取问医生详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return AjaxResult.success(docOrderService.selectDocOrderById(orderId));
    }

    /**
     * 新增问医生
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:add')")
    @Log(title = "问医生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocOrder docOrder)
    {
        return toAjax(docOrderService.insertDocOrder(docOrder));
    }

    /**
     * 修改问医生
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:edit')")
    @Log(title = "问医生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocOrder docOrder)
    {
        return toAjax(docOrderService.updateDocOrder(docOrder));
    }

    /**
     * 删除问医生
     */
    @PreAuthorize("@ss.hasPermi('doc:docOrder:remove')")
    @Log(title = "问医生", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(docOrderService.deleteDocOrderByIds(orderIds));
    }
}
