package com.fs.hospital.controller.hospital;

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.hospital.domain.HospitalWarehouse;
import com.fs.hospital.service.IHospitalWarehouseService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 诊所仓库Controller
 *
 * @author fs
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/hospital/hospitalWarehouse")
public class HospitalWarehouseController extends BaseController
{
    @Autowired
    private IHospitalWarehouseService hospitalWarehouseService;

    /**
     * 查询诊所仓库列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalWarehouse hospitalWarehouse)
    {
        startPage();
        List<HospitalWarehouse> list = hospitalWarehouseService.selectHospitalWarehouseList(hospitalWarehouse);
        return getDataTable(list);
    }

    /**
     * 导出诊所仓库列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:export')")
    @Log(title = "诊所仓库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HospitalWarehouse hospitalWarehouse)
    {
        List<HospitalWarehouse> list = hospitalWarehouseService.selectHospitalWarehouseList(hospitalWarehouse);
        ExcelUtil<HospitalWarehouse> util = new ExcelUtil<HospitalWarehouse>(HospitalWarehouse.class);
        return util.exportExcel(list, "诊所仓库数据");
    }

    /**
     * 获取诊所仓库详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:query')")
    @GetMapping(value = "/{warehouseId}")
    public AjaxResult getInfo(@PathVariable("warehouseId") Long warehouseId)
    {
        return AjaxResult.success(hospitalWarehouseService.selectHospitalWarehouseByWarehouseId(warehouseId));
    }

    /**
     * 新增诊所仓库
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:add')")
    @Log(title = "诊所仓库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalWarehouse hospitalWarehouse)
    {
        return toAjax(hospitalWarehouseService.insertHospitalWarehouse(hospitalWarehouse));
    }

    /**
     * 修改诊所仓库
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:edit')")
    @Log(title = "诊所仓库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalWarehouse hospitalWarehouse)
    {
        return toAjax(hospitalWarehouseService.updateHospitalWarehouse(hospitalWarehouse));
    }

    /**
     * 删除诊所仓库
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalWarehouse:remove')")
    @Log(title = "诊所仓库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseIds}")
    public AjaxResult remove(@PathVariable Long[] warehouseIds)
    {
        return toAjax(hospitalWarehouseService.deleteHospitalWarehouseByWarehouseIds(warehouseIds));
    }
}
