package com.yunfeiyun.agmp.fms.controller;

import com.yunfeiyun.agmp.common.annotation.Log;
import com.yunfeiyun.agmp.common.core.controller.BaseController;
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
import com.yunfeiyun.agmp.common.enums.BusinessType;
import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
import com.yunfeiyun.agmp.fms.domain.TssScanrcd;
import com.yunfeiyun.agmp.fms.domain.reqvo.TssScanrcdReqVo;
import com.yunfeiyun.agmp.fms.domain.resvo.TssScanrcdResVo;
import com.yunfeiyun.agmp.fms.service.ITssScanrcdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 溯源码扫码记录Controller
 * 
 * @author 杨晓辉
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/tss/scanrcd")
public class TssScanrcdController extends BaseController
{
    @Autowired
    private ITssScanrcdService tssScanrcdService;

    /**
     * 查询溯源码扫码记录列表
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:list')")
    @GetMapping("/list")
    public TableDataInfo list(TssScanrcdReqVo tssScanrcdReqVo)
    {
        startPage();
        List<TssScanrcdResVo> list = tssScanrcdService.selectTssScanrcdList(tssScanrcdReqVo);
        return getDataTable(list);
    }



    /**
     * 导出溯源码扫码记录列表
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:export')")
    @Log(title = "溯源码扫码记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TssScanrcd tssScanrcd)
    {
        List<TssScanrcd> list = tssScanrcdService.selectTssScanrcdList(tssScanrcd);
        ExcelUtil<TssScanrcd> util = new ExcelUtil<TssScanrcd>(TssScanrcd.class);
        util.exportExcel(response, list, "溯源码扫码记录数据");
    }

    /**
     * 获取溯源码扫码记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:info')")
    @GetMapping(value = "/info/{scanrcdId}")
    public AjaxResult getInfo(@PathVariable("scanrcdId") String scanrcdId)
    {
        return success(tssScanrcdService.selectTssScanrcdByScanrcdId(scanrcdId));
    }

    /**
     * 新增溯源码扫码记录
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:add')")
    @Log(title = "溯源码扫码记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TssScanrcd tssScanrcd)
    {
        return toAjax(tssScanrcdService.insertTssScanrcd(tssScanrcd));
    }

    /**
     * 修改溯源码扫码记录
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:edit')")
    @Log(title = "溯源码扫码记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody TssScanrcd tssScanrcd)
    {
        return toAjax(tssScanrcdService.updateTssScanrcd(tssScanrcd));
    }

    /**
     * 删除溯源码扫码记录
     */
    @PreAuthorize("@ss.hasPermi('tss:scanrcd:delete')")
    @Log(title = "溯源码扫码记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete/{scanrcdIds}")
    public AjaxResult remove(@PathVariable String[] scanrcdIds)
    {
        return toAjax(tssScanrcdService.deleteTssScanrcdByScanrcdIds(scanrcdIds));
    }
}
