package com.shkj.wms.controller.business;

import java.util.List;

import com.shkj.wms.config.ValidList;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.shkj.common.annotation.Log;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.wms.vo.SysStockDetailQrcodeVo;
import com.shkj.wms.bo.SysStockDetailQrcodeQueryBo;
import com.shkj.wms.bo.SysStockDetailQrcodeAddBo;
import com.shkj.wms.bo.SysStockDetailQrcodeEditBo;
import com.shkj.wms.service.ISysStockDetailQrcodeService;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 已建表-库存明细产品信息Controller
 *
 * @menu 已建表-库存明细产品信息管理
 * @author lch
 * @date 2023-05-07
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/qrcode")
public class SysStockDetailQrcodeController extends BaseController {

    private final ISysStockDetailQrcodeService iSysStockDetailQrcodeService;

    /**
     * 查询已建表-库存明细产品信息列表
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:list')")
    @GetMapping("/list")
    public TableDataInfo<SysStockDetailQrcodeVo> list(SysStockDetailQrcodeQueryBo bo) {
        startPage();
        List<SysStockDetailQrcodeVo> list = iSysStockDetailQrcodeService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出已建表-库存明细产品信息列表
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:export')")
    @GetMapping("/export")
    public void export(HttpServletResponse response, SysStockDetailQrcodeQueryBo bo) {
        List<SysStockDetailQrcodeVo> list = iSysStockDetailQrcodeService.queryList(bo);
        ExcelUtil<SysStockDetailQrcodeVo> util = new ExcelUtil<SysStockDetailQrcodeVo>(SysStockDetailQrcodeVo.class);
        util.exportExcel(response, list, "已建表-库存明细产品信息数据");
    }

    /**
     * 获取已建表-库存明细产品信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:query')")
    @GetMapping("/{id}")
    public Result<SysStockDetailQrcodeVo> getInfo(@PathVariable("id" ) Long id) {
        return iSysStockDetailQrcodeService.queryById(id);
    }

    /**
     * 新增已建表-库存明细产品信息
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:add')")
    @Log(title = "已建表-库存明细产品信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@Valid @RequestBody SysStockDetailQrcodeAddBo bo) {
        return iSysStockDetailQrcodeService.insertByAddBo(bo);
    }

    /**
     * 修改已建表-库存明细产品信息
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:edit')")
    @Log(title = "已建表-库存明细产品信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@Valid @RequestBody SysStockDetailQrcodeEditBo bo) {
        return iSysStockDetailQrcodeService.updateByEditBo(bo);
    }

    /**
     * 删除已建表-库存明细产品信息
     */
    @PreAuthorize("@ss.hasPermi('wms:qrcode:remove')")
    @Log(title = "已建表-库存明细产品信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public Result<Boolean> remove(@Valid @RequestBody ValidList<Long> ids) {
        return iSysStockDetailQrcodeService.deleteWithValidById(ids, true);
    }


}
