package com.ruoyi.inventory.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.inventory.domain.HealthcareInventoryDrugoutType;
import com.ruoyi.inventory.service.IHealthcareInventoryDrugoutTypeService;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库调拨记录Controller
 *
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/system/type")
public class HealthcareInventoryDrugoutTypeController extends BaseController {
    @Autowired
    private IHealthcareInventoryDrugoutTypeService healthcareInventoryDrugoutTypeService;

    /**
     * 查询仓库调拨记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthcareInventoryDrugoutType healthcareInventoryDrugoutType) {
        startPage();
        List<HealthcareInventoryDrugoutType> list = healthcareInventoryDrugoutTypeService.selectHealthcareInventoryDrugoutTypeList(healthcareInventoryDrugoutType);
        return getDataTable(list);
    }

    /**
     * 导出仓库调拨记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "仓库调拨记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthcareInventoryDrugoutType healthcareInventoryDrugoutType) {
        List<HealthcareInventoryDrugoutType> list = healthcareInventoryDrugoutTypeService.selectHealthcareInventoryDrugoutTypeList(healthcareInventoryDrugoutType);
        ExcelUtil<HealthcareInventoryDrugoutType> util = new ExcelUtil<HealthcareInventoryDrugoutType>(HealthcareInventoryDrugoutType.class);
        util.exportExcel(response, list, "仓库调拨记录数据");
    }

    /**
     * 获取仓库调拨记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{outTypeId}")
    public AjaxResult getInfo(@PathVariable("outTypeId") Long outTypeId) {
        return success(healthcareInventoryDrugoutTypeService.selectHealthcareInventoryDrugoutTypeByOutTypeId(outTypeId));
    }

    /**
     * 新增仓库调拨记录
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "仓库调拨记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthcareInventoryDrugoutType healthcareInventoryDrugoutType) {
        return toAjax(healthcareInventoryDrugoutTypeService.insertHealthcareInventoryDrugoutType(healthcareInventoryDrugoutType));
    }

    /**
     * 修改仓库调拨记录
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "仓库调拨记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthcareInventoryDrugoutType healthcareInventoryDrugoutType) {
        return toAjax(healthcareInventoryDrugoutTypeService.updateHealthcareInventoryDrugoutType(healthcareInventoryDrugoutType));
    }

    /**
     * 删除仓库调拨记录
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "仓库调拨记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{outTypeIds}")
    public AjaxResult remove(@PathVariable Long[] outTypeIds) {
        return toAjax(healthcareInventoryDrugoutTypeService.deleteHealthcareInventoryDrugoutTypeByOutTypeIds(outTypeIds));
    }
}
