package com.shkj.wms.controller.base;

import com.shkj.common.annotation.Log;
import com.shkj.common.annotation.RepeatSubmit;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wms.bo.BaseLocationPlcQueryPageBo;
import com.shkj.wms.bo.BaseLocationPlcSaveOrUpdateBo;
import com.shkj.wms.common.SwitchStatusEntity;
import com.shkj.wms.config.ValidList;
import com.shkj.wms.domain.BaseLocationPlc;
import com.shkj.wms.service.IBaseLocationPlcService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 货位资料Controller
 *
 * @menu 货位资料管理
 * @author lch
 * @date 2022-04-23
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/locationPlc")
public class BaseLocationPlcController extends BaseController {

    private final IBaseLocationPlcService iBaseLocationPlcService;

    /**
     * 查询货位资料列表
     */
    @GetMapping("/pageBaseLocationPlc")
    public TableDataInfo<BaseLocationPlc> pageBaseLocationPlc(BaseLocationPlcQueryPageBo bo) {
        startPage();
        List<BaseLocationPlc> list = iBaseLocationPlcService.selectBaseLocationPlcList(bo);
        return getDataTable(list);
    }



    /**
     * 批量导入及新增修改
     * @param list
     * @return
     */
    @PostMapping("/saveOrUpdateBaseLocationPlcs")
    @RepeatSubmit
    public Result<Boolean> saveOrUpdateBaseLocationPlcs(@Valid @RequestBody ValidList<BaseLocationPlcSaveOrUpdateBo> list){
        return iBaseLocationPlcService.saveOrUpdateBaseLocationPlcs(list);
    }




    /**
     * 删除货位资料
     */
    @PostMapping("/removeBaseLocationPlc")
    public Result<Boolean> remove(@Valid @RequestBody ValidList<Long> ids) {
        return iBaseLocationPlcService.deleteWithValidById(ids);
    }
}
