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.ObjectDigital;
import com.persagy.dmp.digital.entity.ObjectRelationProjectCal;
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/relation/project/cal/")
public interface DigitalRelationProjectCalClient {

    /**
     * 查询项目计算关系
     * @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<ObjectRelationProjectCal> 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<ObjectRelationProjectCal>> 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<ObjectRelationProjectCal> 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<ObjectRelationProjectCal>> 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);
}
