package com.fs.hospital.controller.hospital;

import java.util.List;

import com.fs.hospital.vo.HospitalProductCheckOrderItemListHVO;
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.HospitalProductCheckOrderItem;
import com.fs.hospital.service.IHospitalProductCheckOrderItemService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 采购单明细Controller
 *
 * @author fs
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/hospital/hospitalProductCheckOrderItem")
public class HospitalProductCheckOrderItemController extends BaseController
{
    @Autowired
    private IHospitalProductCheckOrderItemService hospitalProductCheckOrderItemService;

    /**
     * 查询采购单明细列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalProductCheckOrderItem hospitalProductCheckOrderItem)
    {
        startPage();
        List<HospitalProductCheckOrderItemListHVO> list = hospitalProductCheckOrderItemService.selectHospitalProductCheckOrderItemListPVO(hospitalProductCheckOrderItem);
        return getDataTable(list);
    }

    /**
     * 导出采购单明细列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:export')")
    @Log(title = "采购单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HospitalProductCheckOrderItem hospitalProductCheckOrderItem)
    {
        List<HospitalProductCheckOrderItem> list = hospitalProductCheckOrderItemService.selectHospitalProductCheckOrderItemList(hospitalProductCheckOrderItem);
        ExcelUtil<HospitalProductCheckOrderItem> util = new ExcelUtil<HospitalProductCheckOrderItem>(HospitalProductCheckOrderItem.class);
        return util.exportExcel(list, "采购单明细数据");
    }

    /**
     * 获取采购单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return AjaxResult.success(hospitalProductCheckOrderItemService.selectHospitalProductCheckOrderItemByItemId(itemId));
    }

    /**
     * 新增采购单明细
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:add')")
    @Log(title = "采购单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalProductCheckOrderItem hospitalProductCheckOrderItem)
    {
        return toAjax(hospitalProductCheckOrderItemService.insertHospitalProductCheckOrderItem(hospitalProductCheckOrderItem));
    }

    /**
     * 修改采购单明细
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:edit')")
    @Log(title = "采购单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalProductCheckOrderItem hospitalProductCheckOrderItem)
    {
        return toAjax(hospitalProductCheckOrderItemService.updateHospitalProductCheckOrderItem(hospitalProductCheckOrderItem));
    }

    /**
     * 删除采购单明细
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalProductCheckOrderItem:remove')")
    @Log(title = "采购单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds)
    {
        return toAjax(hospitalProductCheckOrderItemService.deleteHospitalProductCheckOrderItemByItemIds(itemIds));
    }
}
