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.StockInType;
import com.zg.project.information.service.IStockInTypeService;
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-05-27
 */
@RestController
@RequestMapping("/information/warehousingtype")
public class StockInTypeController extends BaseController
{
    @Autowired
    private IStockInTypeService stockInTypeService;

    /**
     * 查询入库类型列表
     */
    @PreAuthorize("@ss.hasPermi('information:warehousingtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockInType stockInType)
    {
        startPage();
        List<StockInType> list = stockInTypeService.selectStockInTypeList(stockInType);
        return getDataTable(list);
    }

    /**
     * 查询所有入库类型列表
     * @return
     */
    @PreAuthorize("@ss.hasPermi('information:warehousingtype:list')")
    @GetMapping("/getAll")
    public AjaxResult getAll()
    {
        List<StockInType> list = stockInTypeService.selectStockInTypeList(new StockInType());
        return AjaxResult.success(list);
    }
    /**
     * 导出入库类型列表
     */
    @PreAuthorize("@ss.hasPermi('information:warehousingtype:export')")
    @Log(title = "入库类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockInType stockInType)
    {
        List<StockInType> list = stockInTypeService.selectStockInTypeList(stockInType);
        ExcelUtil<StockInType> util = new ExcelUtil<StockInType>(StockInType.class);
        util.exportExcel(response, list, "入库类型数据");
    }

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

    /**
     * 新增入库类型
     */
    @PreAuthorize("@ss.hasPermi('information:warehousingtype:add')")
    @Log(title = "入库类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockInType stockInType)
    {
        return toAjax(stockInTypeService.insertStockInType(stockInType));
    }

    /**
     * 修改入库类型
     */
    @PreAuthorize("@ss.hasPermi('information:warehousingtype:edit')")
    @Log(title = "入库类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockInType stockInType)
    {
        return toAjax(stockInTypeService.updateStockInType(stockInType));
    }

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