package com.ruoyi.web.controller.warehouse.warehouseBusiness;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel;
import com.ruoyi.warehouseBusiness.service.ITWarehousebillsitemsElabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 电子标签Controller
 */
@RestController
@RequestMapping("/warehouseBusiness/label")
public class TWarehouseLabelController extends BaseController {

    @Autowired
    private ITWarehousebillsitemsElabelService labelService;

    @GetMapping("/list")
    public AjaxResult list(TWarehousebillsitemsElabel elabel) {
        return AjaxResult.success(labelService.selectByfPid(elabel.getfPid()));
    }

    @GetMapping("/in-list")
    public AjaxResult inList(Long stockId) {
        return AjaxResult.success(labelService.selectByStockId(stockId));
    }

    @PostMapping("/save")
    @RepeatSubmit
    public AjaxResult save(@RequestBody List<TWarehousebillsitemsElabel> elabelList) {
        return labelService.insert(elabelList);
    }

    @GetMapping("/remove/{fId}")
    @RepeatSubmit
    public AjaxResult remove(@PathVariable("fId") Long fId) {
        labelService.deleteById(fId);
        return AjaxResult.success();
    }

}
