package com.persagy.proxy.report.controller;

import com.persagy.proxy.adm.request.AdmQueryCriteria;
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.relation.model.AdmDtRelation;
import com.persagy.proxy.relation.service.IAdmDtRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ADM 窗户 API
 * @author xujiaheng
 * @date 2021-09-3
 */
@RestController
@RequestMapping("/rel/obj")
public class AdmRelationObjectController {

    @Autowired
    private IAdmDtRelationService service;

    /**
     * 创建
     * @param
     * @return
     * @throws Exception
     */
    @PostMapping("/equip/query")
    public AdmResponse equipRel(@RequestParam(value = "projectId",required = false) String projectId) {
        //组装上下文条件
        InstanceUrlParam context = AdmContextUtil.toDmpContext();
        AdmQueryCriteria criteria = new AdmQueryCriteria();
        criteria.setFilters("projectId = "+context.getProjectId());
        AdmResponse admResponse = service.doQuery(context, criteria, AdmDtRelation.class);
        return admResponse;
    }
}
