package com.persagy.dmp.digital.client;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.persagy.dmp.basic.config.DigitalFeignConfig;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.digital.entity.ObjectRelation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/***
 * Description:对象管理Client
 * @author : lijie
 * @date :2021/8/19 17:38
 * Update By lijie 2021/8/19 17:38
 */
@FeignClient(name = "dmp-rwd", configuration = DigitalFeignConfig.class,
        url = "${persagy.bdtp.rwd.service:}",path = "/rwd/instance/relation/")
public interface DigitalRelationClient {

    /**
     * 查询物理世界对象关系
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param criteria: 查询条件
     * @return 对象关系数组
     */
    @PostMapping("query")
    CommonResult<List<ObjectRelation>> query(@RequestParam("groupCode") String groupCode,
                                             @RequestParam("projectId") String projectId,
                                             @RequestParam("appId") String appId,
                                             @RequestParam("userId") String userId,
                                             @RequestBody QueryCriteria criteria);
    /**
     * 新增物理世界对象关系-单个新增
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param node: 新增对象
     * @return 对象关系
     */
    @PostMapping("createOne")
    CommonResult<ObjectRelation> createOne(@RequestParam("groupCode") String groupCode,
                                           @RequestParam("projectId") String projectId,
                                           @RequestParam("appId") String appId,
                                           @RequestParam("userId") String userId,
                                           @RequestBody ObjectNode node);
    /**
     * 新增物理世界对象关系-批量新增
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param nodes: 新增对象集合
     * @return 对象关系数组
     */
    @PostMapping("create")
    CommonResult<List<ObjectRelation>> create(@RequestParam("groupCode") String groupCode,
                                              @RequestParam("projectId") String projectId,
                                              @RequestParam("appId") String appId,
                                              @RequestParam("userId") String userId,
                                              @RequestBody List<ObjectNode> nodes);
    /**
     * 更新物理世界对象关系-单个更新
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param node: 更新对象
     * @return 对象关系
     */
    @PostMapping("updateOne")
    CommonResult<ObjectRelation> updateOne(@RequestParam("groupCode") String groupCode,
                                           @RequestParam("projectId") String projectId,
                                           @RequestParam("appId") String appId,
                                           @RequestParam("userId") String userId,
                                           @RequestBody ObjectNode node);
    /**
     * 更新物理世界对象关系-批量更新
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param nodes: 更新对象集合
     * @return 对象关系数组
     */
    @PostMapping("update")
    CommonResult<List<ObjectRelation>> update(@RequestParam("groupCode") String groupCode,
                                              @RequestParam("projectId") String projectId,
                                              @RequestParam("appId") String appId,
                                              @RequestParam("userId") String userId,
                                              @RequestBody List<ObjectNode> nodes);
    /**
     * 删除物理世界对象关系-单个删除
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param id: 关系id
     * @return void
     */
    @PostMapping("deleteOne")
    CommonResult<Void> deleteOne(@RequestParam("groupCode") String groupCode,
                                 @RequestParam("projectId") String projectId,
                                 @RequestParam("appId") String appId,
                                 @RequestParam("userId") String userId,
                                 @RequestBody String id);
    /**
     * 删除物理世界对象关系-批量删除
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param criteria: 关系id集合
     * @return void
     */
    @PostMapping("delete")
    CommonResult<List<ObjectRelation>> delete(@RequestParam("groupCode") String groupCode,
                              @RequestParam("projectId") String projectId,
                              @RequestParam("appId") String appId,
                              @RequestParam("userId") String userId,
                              @RequestBody Object criteria);
}
