package com.persagy.proxy.dictionary.controller;

import com.persagy.proxy.adm.request.AdmResponse;
import com.persagy.proxy.adm.utils.AdmContextUtil;
import com.persagy.proxy.common.entity.InstanceUrlParam;
import com.persagy.proxy.dictionary.model.AdmPlanarEquipRequests;
import com.persagy.proxy.dictionary.service.IAdmPlanarService;
import com.persagy.proxy.object.model.AdmEquipment;
import com.persagy.proxy.object.model.AdmSpace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AdmLabslController
 * @Description: 平面图接口
 * @Author linhuili
 * @Date 2021/9/18 13:01
 * @Version V1.0
 **/
@RestController
@RequestMapping("/planar")
@Slf4j
public class AdmPlanarController {

    @Autowired
    private IAdmPlanarService service;

    /**
     * 查询平面图设备信息
     * @return
     * @throws Exception
     */
    @PostMapping("/equip")
    public AdmResponse queryPlanarEquip(@RequestParam(value = "projectId",required = false) String projectId,
                                          @RequestBody AdmPlanarEquipRequests requests) throws Exception {
        InstanceUrlParam context = AdmContextUtil.toDmpContext();
        if(requests == null){
            throw new Exception("请求参数不能为空");
        }
        return service.queryPlanarEquip(context,requests, AdmEquipment.class);
    }

    /**
     * 查询平面图空间信息
     * @return
     * @throws Exception
     */
    @PostMapping("/space")
    public AdmResponse queryPlanarSpace(@RequestParam(value = "projectId",required = false) String projectId,
                                  @RequestBody AdmPlanarEquipRequests requests) throws Exception {
        InstanceUrlParam context = AdmContextUtil.toDmpContext();
        if(requests == null){
            throw new Exception("请求参数不能为空");
        }
        return service.queryPlanarSpace(context,requests, AdmSpace.class);
    }
}
