package com.persagy.dmp.digital.client;

import cn.hutool.extra.spring.SpringUtil;
import com.persagy.dmp.basic.dto.RequestData;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.digital.entity.ObjectRelation;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/***
 * Description: 关系计算入口 Client 门面
 * @author : lijie
 * @date :2021/9/3 21:09
 * Update By lijie 2021/9/3 21:09
 */
public class DigitalRelationCaclFacade {

    private static DigitalRelationCaclClient client = SpringUtil.getBean(DigitalRelationCaclClient.class);

    /**
     * 根据id,localId,name,localName,CADID及关系类型信息,对象分类信息创建关系
     * @param groupCode: 集团编码
     * @param projectId: 项目id
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("createObjRelationsByKeywordAndObjType")
    public static List<ObjectRelation> createObjRelationsByKeywordAndObjType(String groupCode, String projectId,
                                                                      String appId, String userId,
                                                                      RequestData requestData){
        CommonResult<List<ObjectRelation>> relations =
                client.createObjRelationsByKeywordAndObjType(groupCode, projectId, appId, userId, requestData);
        return relations.getData();
    }
    /**
     * 根据fromId,toId,relType,graphCode删除关系
     * @param groupCode: 集团编码
     * @param projectId: 项目id
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param objectRelation: 请求参数
     * @return
     */
    @PostMapping("deleteObjRelationsByRelId")
    public static List<ObjectRelation> deleteObjRelationsByRelId(String groupCode, String projectId,
                                                          String appId, String userId,
                                                          ObjectRelation objectRelation){
        CommonResult<List<ObjectRelation>> relations =
                client.deleteObjRelationsByRelId(groupCode, projectId, appId, userId, objectRelation);
        return relations.getData();
    }
    /**
     * 关系计算
     * @param groupCode: 集团编码
     * @param projectId: 项目id
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("calculatingObjRelation")
    public static CommonResult<List<ObjectRelation>> calculatingObjRelationPrototype(String groupCode, String projectId,
                                                          String appId, String userId,
                                                          RequestData requestData){
        return client.calculatingObjRelation(groupCode, projectId, appId, userId, requestData);
    }
}
