package com.zehong.web.controller.gasBottleTrack;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.TGasBottleTrackRecord;
import com.zehong.system.service.ITGasBottleTrackRecordService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 气瓶追溯Controller
 *
 * @author zehong
 * @date 2023-08-18
 */
@RestController
@RequestMapping("/track/record")
public class TGasBottleTrackRecordController extends BaseController
{
    @Autowired
    private ITGasBottleTrackRecordService tGasBottleTrackRecordService;

    /**
     * 查询气瓶追溯列表
     */
    @PreAuthorize("@ss.hasPermi('track:record:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody TGasBottleTrackRecord tGasBottleTrackRecord)
    {
        startPage();
        List<TGasBottleTrackRecord> list = tGasBottleTrackRecordService.selectTGasBottleTrackRecordList(tGasBottleTrackRecord);
        return getDataTable(list);
    }

    @PostMapping("/bottleTrackRecordList")
    public AjaxResult bottleTrackRecordList(@RequestBody TGasBottleTrackRecord tGasBottleTrackRecord)
    {
        List<TGasBottleTrackRecord> list = tGasBottleTrackRecordService.selectTGasBottleTrackRecordList(tGasBottleTrackRecord);
        return AjaxResult.success(list);
    }

    /**
     * 导出气瓶追溯列表
     */
    @PreAuthorize("@ss.hasPermi('track:record:export')")
    @Log(title = "气瓶追溯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(@RequestBody TGasBottleTrackRecord tGasBottleTrackRecord)
    {
        List<TGasBottleTrackRecord> list = tGasBottleTrackRecordService.selectTGasBottleTrackRecordList(tGasBottleTrackRecord);
        ExcelUtil<TGasBottleTrackRecord> util = new ExcelUtil<TGasBottleTrackRecord>(TGasBottleTrackRecord.class);
        return util.exportExcel(list, "气瓶追溯数据");
    }

    /**
     * 获取气瓶追溯详细信息
     */
    @PreAuthorize("@ss.hasPermi('track:record:query')")
    @GetMapping(value = "/{trackRecordId}")
    public AjaxResult getInfo(@PathVariable("trackRecordId") Long trackRecordId)
    {
        return AjaxResult.success(tGasBottleTrackRecordService.selectTGasBottleTrackRecordById(trackRecordId));
    }

    /**
     * 新增气瓶追溯
     */
    @PreAuthorize("@ss.hasPermi('track:record:add')")
    @Log(title = "气瓶追溯", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGasBottleTrackRecord tGasBottleTrackRecord)
    {
        return toAjax(tGasBottleTrackRecordService.insertTGasBottleTrackRecord(tGasBottleTrackRecord));
    }

    /**
     * 修改气瓶追溯
     */
    @PreAuthorize("@ss.hasPermi('track:record:edit')")
    @Log(title = "气瓶追溯", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGasBottleTrackRecord tGasBottleTrackRecord)
    {
        return toAjax(tGasBottleTrackRecordService.updateTGasBottleTrackRecord(tGasBottleTrackRecord));
    }

    /**
     * 删除气瓶追溯
     */
    @PreAuthorize("@ss.hasPermi('track:record:remove')")
    @Log(title = "气瓶追溯", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trackRecordIds}")
    public AjaxResult remove(@PathVariable Long[] trackRecordIds)
    {
        return toAjax(tGasBottleTrackRecordService.deleteTGasBottleTrackRecordByIds(trackRecordIds));
    }
}
