package cn.estsh.i3plus.ext.mes.apiservice.controller.base;

import cn.estsh.i3plus.ext.mes.api.base.IContainerUnbundleCloudService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文件描述
 * 容器解绑
 *
 * @author xiangming.liao
 * @date 2021年04月06日 16:57
 */
@RestController
@RequestMapping(CommonConstWords.BASE_URL_MES + "/container")
public class ContainerUnbundleCloudController {

    @Autowired
    private IContainerUnbundleCloudService containerUnbundleCloudService;

    @PutMapping("/container-unbundle")
    @ApiOperation(value = "容器解绑")
    public ResultBean containerUnbundle(@RequestParam("sn") String sn,
                                        @RequestParam("userName") String userName,
                                        @RequestParam("organizeCode") String organizeCode) {
        try {
            containerUnbundleCloudService.doContainerUnbundle(sn, userName, organizeCode);
            return ResultBean.success("解绑成功");
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
