package com.zg.project.information.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.project.information.domain.StockOutType;
import com.zg.project.information.service.IStockOutTypeService;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;

/**
 * 出库类型Controller
 * 
 * @author zg
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/information/outtype")
public class StockOutTypeController extends BaseController
{
    @Autowired
    private IStockOutTypeService stockOutTypeService;

    /**
     * 查询出库类型列表
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockOutType stockOutType)
    {
        startPage();
        List<StockOutType> list = stockOutTypeService.selectStockOutTypeList(stockOutType);
        return getDataTable(list);
    }

    /**
     * 导出出库类型列表
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:export')")
    @Log(title = "出库类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockOutType stockOutType)
    {
        List<StockOutType> list = stockOutTypeService.selectStockOutTypeList(stockOutType);
        ExcelUtil<StockOutType> util = new ExcelUtil<StockOutType>(StockOutType.class);
        util.exportExcel(response, list, "出库类型数据");
    }

    /**
     * 获取出库类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stockOutTypeService.selectStockOutTypeById(id));
    }

    /**
     * 新增出库类型
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:add')")
    @Log(title = "出库类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockOutType stockOutType)
    {
        return toAjax(stockOutTypeService.insertStockOutType(stockOutType));
    }

    /**
     * 修改出库类型
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:edit')")
    @Log(title = "出库类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockOutType stockOutType)
    {
        return toAjax(stockOutTypeService.updateStockOutType(stockOutType));
    }

    /**
     * 删除出库类型
     */
    @PreAuthorize("@ss.hasPermi('information:outtype:remove')")
    @Log(title = "出库类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stockOutTypeService.deleteStockOutTypeByIds(ids));
    }
}
