package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsDoctorBillParam;
import com.fs.his.vo.FsDoctorBillVO;
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.his.domain.FsDoctorBill;
import com.fs.his.service.IFsDoctorBillService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 医生账单记录Controller
 *
 * @author fs
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/his/doctorBill")
public class FsDoctorBillController extends BaseController
{
    @Autowired
    private IFsDoctorBillService fsDoctorBillService;

    /**
     * 查询医生账单记录列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsDoctorBillParam fsDoctorBill)
    {
        startPage();
        List<FsDoctorBillVO> list = fsDoctorBillService.selectFsDoctorBillListVO(fsDoctorBill);
        return getDataTable(list);
    }

    /**
     * 导出医生账单记录列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:export')")
    @Log(title = "医生账单记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDoctorBillParam fsDoctorBill)
    {
        List<FsDoctorBillVO> list = fsDoctorBillService.selectFsDoctorBillListVO(fsDoctorBill);
        ExcelUtil<FsDoctorBillVO> util = new ExcelUtil<FsDoctorBillVO>(FsDoctorBillVO.class);
        return util.exportExcel(list, "医生账单记录数据");
    }

    /**
     * 获取医生账单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:query')")
    @GetMapping(value = "/{billId}")
    public AjaxResult getInfo(@PathVariable("billId") Long billId)
    {
        return AjaxResult.success(fsDoctorBillService.selectFsDoctorBillByBillId(billId));
    }

    /**
     * 新增医生账单记录
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:add')")
    @Log(title = "医生账单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDoctorBill fsDoctorBill)
    {
        return toAjax(fsDoctorBillService.insertFsDoctorBill(fsDoctorBill));
    }

    /**
     * 修改医生账单记录
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:edit')")
    @Log(title = "医生账单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDoctorBill fsDoctorBill)
    {
        return toAjax(fsDoctorBillService.updateFsDoctorBill(fsDoctorBill));
    }

    /**
     * 删除医生账单记录
     */
    @PreAuthorize("@ss.hasPermi('his:doctorBill:remove')")
    @Log(title = "医生账单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billIds}")
    public AjaxResult remove(@PathVariable Long[] billIds)
    {
        return toAjax(fsDoctorBillService.deleteFsDoctorBillByBillIds(billIds));
    }
}
