package com.fs.his.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.his.domain.FsDoctorProduct;
import com.fs.his.service.IFsDoctorProductService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 医生常用商品Controller
 * 
 * @author fs
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/his/doctorProduct")
public class FsDoctorProductController extends BaseController
{
    @Autowired
    private IFsDoctorProductService fsDoctorProductService;

    /**
     * 查询医生常用商品列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsDoctorProduct fsDoctorProduct)
    {
        startPage();
        List<FsDoctorProduct> list = fsDoctorProductService.selectFsDoctorProductList(fsDoctorProduct);
        return getDataTable(list);
    }

    /**
     * 导出医生常用商品列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:export')")
    @Log(title = "医生常用商品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDoctorProduct fsDoctorProduct)
    {
        List<FsDoctorProduct> list = fsDoctorProductService.selectFsDoctorProductList(fsDoctorProduct);
        ExcelUtil<FsDoctorProduct> util = new ExcelUtil<FsDoctorProduct>(FsDoctorProduct.class);
        return util.exportExcel(list, "医生常用商品数据");
    }

    /**
     * 获取医生常用商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsDoctorProductService.selectFsDoctorProductById(id));
    }

    /**
     * 新增医生常用商品
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:add')")
    @Log(title = "医生常用商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDoctorProduct fsDoctorProduct)
    {
        return toAjax(fsDoctorProductService.insertFsDoctorProduct(fsDoctorProduct));
    }

    /**
     * 修改医生常用商品
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:edit')")
    @Log(title = "医生常用商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDoctorProduct fsDoctorProduct)
    {
        return toAjax(fsDoctorProductService.updateFsDoctorProduct(fsDoctorProduct));
    }

    /**
     * 删除医生常用商品
     */
    @PreAuthorize("@ss.hasPermi('his:doctorProduct:remove')")
    @Log(title = "医生常用商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsDoctorProductService.deleteFsDoctorProductByIds(ids));
    }
}
