package com.shkj.wms.controller.temp;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.wms.bo.BaseLocationPlcQueryPageBo;
import com.shkj.wms.bo.BaseLogicareaVmQueryListBo;
import com.shkj.wms.bo.BaseLogicareaVmSaveOrUpdateBo;
import com.shkj.wms.config.ValidList;
import com.shkj.wms.domain.BaseLocationPlc;
import com.shkj.wms.domain.BaseLogicAreaDerive;
import com.shkj.wms.service.IBaseLogicareaVmService;
import com.shkj.wms.vo.BaseLogicareaDeriveVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 逻辑区域与车型关系Controller
 *
 * @author zjx
 * @date 2023-04-19
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/vehiclemodel")
public class BaseLogicareaVmController extends BaseController
{
    @Autowired
    private IBaseLogicareaVmService iBaseLogicareaVmService;


    /**
     * 查询逻辑区域派生关系列表
     */
    @GetMapping("/list")
    public Result<List<BaseLogicAreaDerive>> list() {
        return Result.ok().data(iBaseLogicareaVmService.list(new LambdaQueryWrapper<BaseLogicAreaDerive>()
                .orderByDesc(BaseLogicAreaDerive::getCreateTime)));
    }


    /**
     * 查询逻辑区域派生关系列表
     */
    @GetMapping("/queryBaseLogicAreaDeriveList")
    public TableDataInfo<BaseLocationPlc> pageBaseLocationPlc(BaseLogicareaVmQueryListBo bo) {
        startPage();
        List<BaseLogicareaDeriveVo> list = iBaseLogicareaVmService.queryBaseLogicAreaVmList(bo);
        return getDataTable(list);
    }


    /**
     * 保存或修改区域派生信息
     */
    @PostMapping("/saveOrUpdateBaseLogicAreaVm")
    @RepeatSubmit
    public Result<Boolean> saveOrUpdateBaseLogicAreaVm(@Valid @RequestBody ValidList<BaseLogicareaVmSaveOrUpdateBo> list){
        return iBaseLogicareaVmService.saveOrUpdateBaseLogicAreaVm(list);
    }


}
