package com.zehong.web.controller.lpgRegulation;

import java.util.List;
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.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.TLpgTraceBack;
import com.zehong.system.service.ITLpgTraceBackService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 气瓶追溯Controller
 * 
 * @author zehong
 * @date 2026-03-20
 */
@RestController
@RequestMapping("/lpgRegulation/traceback")
public class TLpgTraceBackController extends BaseController
{
    @Autowired
    private ITLpgTraceBackService tLpgTraceBackService;

    /**
     * 查询气瓶追溯列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TLpgTraceBack tLpgTraceBack)
    {
        startPage();
        List<TLpgTraceBack> list = tLpgTraceBackService.selectTLpgTraceBackList(tLpgTraceBack);
        return getDataTable(list);
    }

    /**
     * 导出气瓶追溯列表
     */
    @Log(title = "气瓶追溯", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TLpgTraceBack tLpgTraceBack)
    {
        List<TLpgTraceBack> list = tLpgTraceBackService.selectTLpgTraceBackList(tLpgTraceBack);
        ExcelUtil<TLpgTraceBack> util = new ExcelUtil<TLpgTraceBack>(TLpgTraceBack.class);
        return util.exportExcel(list, "气瓶追溯数据");
    }

    /**
     * 获取气瓶追溯详细信息
     */
    @GetMapping(value = "/{traceId}")
    public AjaxResult getInfo(@PathVariable("traceId") Long traceId)
    {
        return AjaxResult.success(tLpgTraceBackService.selectTLpgTraceBackById(traceId));
    }

    /**
     * 新增气瓶追溯
     */
    @Log(title = "气瓶追溯", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLpgTraceBack tLpgTraceBack)
    {
        return toAjax(tLpgTraceBackService.insertTLpgTraceBack(tLpgTraceBack));
    }

    /**
     * 修改气瓶追溯
     */
    @Log(title = "气瓶追溯", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLpgTraceBack tLpgTraceBack)
    {
        return toAjax(tLpgTraceBackService.updateTLpgTraceBack(tLpgTraceBack));
    }

    /**
     * 删除气瓶追溯
     */
    @Log(title = "气瓶追溯", businessType = BusinessType.DELETE)
	@DeleteMapping("/{traceIds}")
    public AjaxResult remove(@PathVariable Long[] traceIds)
    {
        return toAjax(tLpgTraceBackService.deleteTLpgTraceBackByIds(traceIds));
    }
}
