package com.hw.mes.controller;

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

import com.hw.common.security.annotation.InnerAuth;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.mes.service.IMesBaseBarcodeInfoService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 条码信息Controller
 *
 * @author xs
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/barcode")
public class MesBaseBarcodeInfoController extends BaseController
{
    @Autowired
    private IMesBaseBarcodeInfoService mesBaseBarcodeInfoService;

    /**
     * 查询条码信息列表
     */
    @RequiresPermissions("mes:barcode:list")
    @GetMapping("/list")
    public TableDataInfo list(MesBaseBarcodeInfo mesBaseBarcodeInfo)
    {
        startPage();
        List<MesBaseBarcodeInfo> list = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoList(mesBaseBarcodeInfo);
        return getDataTable(list);
    }

    /**
     * 导出条码信息列表
     */
    @RequiresPermissions("mes:barcode:export")
    @Log(title = "条码信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBaseBarcodeInfo mesBaseBarcodeInfo)
    {
        List<MesBaseBarcodeInfo> list = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoList(mesBaseBarcodeInfo);
        ExcelUtil<MesBaseBarcodeInfo> util = new ExcelUtil<MesBaseBarcodeInfo>(MesBaseBarcodeInfo.class);
        util.exportExcel(response, list, "条码信息数据");
    }

    /**
     * 获取条码信息详细信息
     */
    @RequiresPermissions("mes:barcode:query")
    @GetMapping(value = "/{barcodeId}")
    public AjaxResult getInfo(@PathVariable("barcodeId") Long barcodeId)
    {
        return success(mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoByBarcodeId(barcodeId));
    }

    /**
     * 新增条码信息
     */
    @RequiresPermissions("mes:barcode:add")
    @Log(title = "条码信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBaseBarcodeInfo mesBaseBarcodeInfo)
    {
        return toAjax(mesBaseBarcodeInfoService.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo));
    }

    /**
     * 修改条码信息
     */
    @RequiresPermissions("mes:barcode:edit")
    @Log(title = "条码信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBaseBarcodeInfo mesBaseBarcodeInfo)
    {
        return toAjax(mesBaseBarcodeInfoService.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo));
    }

    /**
     * 删除条码信息
     */
    @RequiresPermissions("mes:barcode:remove")
    @Log(title = "条码信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{barcodeIds}")
    public AjaxResult remove(@PathVariable Long[] barcodeIds)
    {
        return toAjax(mesBaseBarcodeInfoService.deleteMesBaseBarcodeInfoByBarcodeIds(barcodeIds));
    }




    /**
     * 根据条码信息获取条码信息详细信息
     */
    @InnerAuth
    @GetMapping(value = "/getBarcode/{barcodeInfo}")
    public AjaxResult getInfo(@PathVariable("barcodeInfo") String barcodeInfo)
    {
        return success(mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoByBarcodeInfo(barcodeInfo));
    }
}
