package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsDoctorPriceParam;
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.FsDoctorPrice;
import com.fs.his.service.IFsDoctorPriceService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 医生价目Controller
 *
 * @author fs
 * @date 2023-07-31
 */
@RestController
@RequestMapping("/his/price")
public class FsDoctorPriceController extends BaseController
{
    @Autowired
    private IFsDoctorPriceService fsDoctorPriceService;

    /**
     * 查询医生价目列表
     */
    @PreAuthorize("@ss.hasPermi('his:price:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsDoctorPrice fsDoctorPrice)
    {
        startPage();
        List<FsDoctorPrice> list = fsDoctorPriceService.selectFsDoctorPriceList(fsDoctorPrice);
        return getDataTable(list);
    }

    /**
     * 导出医生价目列表
     */
    @PreAuthorize("@ss.hasPermi('his:price:export')")
    @Log(title = "医生价目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDoctorPrice fsDoctorPrice)
    {
        List<FsDoctorPrice> list = fsDoctorPriceService.selectFsDoctorPriceList(fsDoctorPrice);
        ExcelUtil<FsDoctorPrice> util = new ExcelUtil<FsDoctorPrice>(FsDoctorPrice.class);
        return util.exportExcel(list, "医生价目数据");
    }

    /**
     * 获取医生价目详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:price:query')")
    @GetMapping(value = "/{priceId}")
    public AjaxResult getInfo(@PathVariable("priceId") Long priceId)
    {
        return AjaxResult.success(fsDoctorPriceService.selectFsDoctorPriceByPriceId(priceId));
    }

    /**
     * 新增医生价目
     */
    @PreAuthorize("@ss.hasPermi('his:price:add')")
    @Log(title = "医生价目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDoctorPrice fsDoctorPrice)
    {
        return toAjax(fsDoctorPriceService.insertFsDoctorPrice(fsDoctorPrice));
    }

    /**
     * 修改医生价目
     */
    @PreAuthorize("@ss.hasPermi('his:price:edit')")
    @Log(title = "医生价目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDoctorPrice fsDoctorPrice)
    {
        return toAjax(fsDoctorPriceService.updateFsDoctorPrice(fsDoctorPrice));
    }

    /**
     * 删除医生价目
     */
    @PreAuthorize("@ss.hasPermi('his:price:remove')")
    @Log(title = "医生价目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{priceIds}")
    public AjaxResult remove(@PathVariable Long[] priceIds)
    {
        return toAjax(fsDoctorPriceService.deleteFsDoctorPriceByPriceIds(priceIds));
    }


    /**
     * 获取医生价目详细信息
     */
    @GetMapping("/getDoctorPrice/{doctorId}")
    public AjaxResult getDoctorPrice(@PathVariable("doctorId") Long doctorId)
    {
        return AjaxResult.success(fsDoctorPriceService.selectDoctorPriceByDoctorId(doctorId));
    }


}
