package com.sw.mes.fls.controller;

import com.sw.mes.core.dto.mes.pc.yb.ProductionBindingTrayDto;
import com.sw.mes.core.response.Result;
import com.sw.mes.core.response.ResultGenerator;
import com.sw.mes.fls.service.ProductionBindingTrayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author wanghao
 * @Date: 2022/7/4
 * @Modified By:
 */
@RestController
@Api(description = "方棒托盘绑定")
@RequestMapping("/fbProductionBindingTray")
public class FbProductionBindingTrayController {

    @Autowired
    private ProductionBindingTrayService productionBindingTrayService;

    @ApiOperation(value = "托盘绑定单晶接口")
    @PostMapping("/fbBindingTray")
    public Result create(@RequestBody @Valid @ApiParam(value = "ProductionBindingTray对象") ProductionBindingTrayDto productionBindingTrayDto, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        }

        return this.productionBindingTrayService.bindingCrystalFb(productionBindingTrayDto);
    }
}
