package com.zehong.web.controller.track;

import java.util.List;

import com.zehong.system.domain.vo.InHouseVo;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.track.TProductStore;
import com.zehong.system.service.track.ITProductStoreService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 配件Controller
 * 
 * @author zehong
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/track/store")
public class TProductStoreController extends BaseController
{
    @Autowired
    private ITProductStoreService tProductStoreService;

    /**
     * 查询配件列表
     */
   // @PreAuthorize("@ss.hasPermi('system:store:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductStore tProductStore)
    {
        startPage();
        List<TProductStore> list = tProductStoreService.selectTProductStoreList(tProductStore);
        return getDataTable(list);
    }

    @GetMapping("/storeList")
    public AjaxResult storeList(TProductStore tProductStore)
    {
        List<TProductStore> list = tProductStoreService.selectTProductStoreList(tProductStore);
        return AjaxResult.success(list);
    }

    /**
     * 导出配件列表
     */
    //@PreAuthorize("@ss.hasPermi('system:store:export')")
    @Log(title = "配件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductStore tProductStore)
    {
        List<TProductStore> list = tProductStoreService.selectTProductStoreList(tProductStore);
        ExcelUtil<TProductStore> util = new ExcelUtil<TProductStore>(TProductStore.class);
        return util.exportExcel(list, "配件数据");
    }

    /**
     * 获取配件详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:store:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductStoreService.selectTProductStoreById(id));
    }

    /**
     * 新增配件
     */
    //@PreAuthorize("@ss.hasPermi('system:store:add')")
    @Log(title = "配件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductStore tProductStore)
    {
        return toAjax(tProductStoreService.insertTProductStore(tProductStore));
    }

    /**
     * 修改配件
     */
    //@PreAuthorize("@ss.hasPermi('system:store:edit')")
    @Log(title = "配件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductStore tProductStore)
    {
        return toAjax(tProductStoreService.updateTProductStore(tProductStore));
    }

    /**
     * 删除配件
     */
    //@PreAuthorize("@ss.hasPermi('system:store:remove')")
    @Log(title = "配件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductStoreService.deleteTProductStoreByIds(ids));
    }

    /**
     * 入库信息
     * @param storeInfo
     * @return
     */
    @PostMapping("/inHouse")
    public AjaxResult inHouse(@RequestBody List<InHouseVo> storeInfo){
        return toAjax(tProductStoreService.inHouse(storeInfo));
    }
}
