package com.zehong.web.controller.track;

import java.util.List;

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.TProductStoreLog;
import com.zehong.system.service.track.ITProductStoreLogService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 配件入库记录Controller
 * 
 * @author zehong
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/track/storeLog")
public class TProductStoreLogController extends BaseController
{
    @Autowired
    private ITProductStoreLogService tProductStoreLogService;

    /**
     * 查询配件入库记录列表
     */
   // @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductStoreLog tProductStoreLog)
    {
        startPage();
        List<TProductStoreLog> list = tProductStoreLogService.selectTProductStoreLogList(tProductStoreLog);
        return getDataTable(list);
    }

    /**
     * 导出配件入库记录列表
     */
    //@PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "配件入库记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductStoreLog tProductStoreLog)
    {
        List<TProductStoreLog> list = tProductStoreLogService.selectTProductStoreLogList(tProductStoreLog);
        ExcelUtil<TProductStoreLog> util = new ExcelUtil<TProductStoreLog>(TProductStoreLog.class);
        return util.exportExcel(list, "配件入库记录数据");
    }

    /**
     * 获取配件入库记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductStoreLogService.selectTProductStoreLogById(id));
    }

    /**
     * 新增配件入库记录
     */
    //@PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "配件入库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductStoreLog tProductStoreLog)
    {
        return toAjax(tProductStoreLogService.insertTProductStoreLog(tProductStoreLog));
    }

    /**
     * 修改配件入库记录
     */
    //@PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "配件入库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductStoreLog tProductStoreLog)
    {
        return toAjax(tProductStoreLogService.updateTProductStoreLog(tProductStoreLog));
    }

    /**
     * 删除配件入库记录
     */
    //@PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "配件入库记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductStoreLogService.deleteTProductStoreLogByIds(ids));
    }
}
