package com.persagy.proxy.calculation.controller;

import com.persagy.dmp.common.exception.BusinessException;
import com.persagy.proxy.adm.request.AdmResponse;
import com.persagy.proxy.adm.utils.AdmContextUtil;
import com.persagy.proxy.dictionary.model.AdmModelRel;
import com.persagy.proxy.dictionary.service.IAdmModelRelService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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;

/**
 * @ClassName AdmModelRelController
 * @Description: 模型修改设备元空间的建筑楼层信息
 * @Author linhuili
 * @Date 2021/8/31 14:30
 * @Version V1.0
 **/
@RestController
@RequestMapping("/rel/update")
@Slf4j
public class AdmModelRelController {

    @Autowired
    private IAdmModelRelService service;

    /**
     * 模型修改设备元空间的建筑楼层信息
     * @param admModelRel
     * @return
     * @throws Exception
     */
    @PostMapping("/equip-ispace")
    public AdmResponse update(@RequestBody AdmModelRel admModelRel) throws Exception {
        if(StringUtils.isEmpty(admModelRel.getModelId())){
            throw new BusinessException("模型ID不能为空");
        }
        if(StringUtils.isEmpty(admModelRel.getFloorId())){
            throw new BusinessException("楼层ID不能为空");
        }
        service.doUpdateModelInfo(AdmContextUtil.toDmpContext(), AdmModelRel.class,admModelRel);
        return AdmResponse.success();
    }

}
