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.dto.RequestData;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.digital.entity.ObjectDigital;
import com.persagy.dmp.define.entity.ObjectTypeDefine;
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;
import java.util.Set;

/***
 * 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/object/")
public interface DigitalObjectClient {

    /**
     * 根据项目id批量查询项目信息
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param projectIds: 项目id数组
     * @return 对象数组
     */
    @PostMapping("batchQueryProjectByIds")
    CommonResult<List<ObjectDigital>> batchQueryProjectByIds(
            @RequestParam("groupCode") String groupCode,
            @RequestParam("projectId") String projectId,
            @RequestParam("appId") String appId,
            @RequestParam("userId") String userId,
            @RequestBody Set<String> projectIds);

    /**
     * 根据管理分区id批量查询项目信息
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 查询条件
     * @return 对象数组
     */
    @PostMapping("batchQueryProjectByGroupManageZoneIds")
    CommonResult<List<ObjectDigital>> batchQueryProjectByGroupManageZoneIds(
            @RequestParam("groupCode") String groupCode,
            @RequestParam("projectId") String projectId,
            @RequestParam("appId") String appId,
            @RequestParam("userId") String userId,
            @RequestBody RequestData requestData);

    /**
     * 查询物理世界对象
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param criteria: 查询条件
     * @return 对象数组
     */
    @PostMapping("query")
    CommonResult<List<ObjectNode>> 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<ObjectDigital> 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<ObjectDigital>> 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<ObjectDigital> 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<ObjectDigital>> 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 ids: 对象id集合
     * @return void
     */
    @PostMapping("delete")
    CommonResult<Void> delete(@RequestParam("groupCode") String groupCode,
                              @RequestParam("projectId") String projectId,
                              @RequestParam("appId") String appId,
                              @RequestParam("userId") String userId,
                              @RequestBody List<String> ids);
    /**
     * 根据上级id查询下级关联对象
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return void
     */
    @PostMapping("queryObjectListSuperiorId")
    CommonResult<List<ObjectDigital>> queryObjectListSuperiorId(@RequestParam("groupCode") String groupCode,
                              @RequestParam("projectId") String projectId,
                              @RequestParam("appId") String appId,
                              @RequestParam("userId") String userId,
                              @RequestBody RequestData requestData);
    /**
     * 根据上级id查询下级关联对象
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return void
     */
    @PostMapping("queryObjectListByGraphCodeAndRelCode")
    CommonResult<List<ObjectDigital>> queryObjectListByGraphCodeAndRelCode(
                              @RequestParam("groupCode") String groupCode,
                              @RequestParam("projectId") String projectId,
                              @RequestParam("appId") String appId,
                              @RequestParam("userId") String userId,
                              @RequestBody RequestData requestData);
    /**
     * 根据对象id批量更新对象的classCode
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param objectDigitals: 请求参数
     * @return void
     */
    @PostMapping("batchUpdateClassCodesByIds")
    CommonResult<List<ObjectDigital>> batchUpdateClassCodesByIds(
                              @RequestParam("groupCode") String groupCode,
                              @RequestParam("projectId") String projectId,
                              @RequestParam("appId") String appId,
                              @RequestParam("userId") String userId,
                              @RequestBody List<ObjectDigital> objectDigitals);
}
