package com.persagy.adm.diagram.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.define.entity.GraphDefine;
import com.persagy.dmp.define.entity.RelationDefine;
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;

@FeignClient(name = "dmp-rwd", configuration = DigitalFeignConfig.class,
		url = "${persagy.bdtp.rwd.service:}")
public interface RwdClient {

	/**
	 * 查询类型定义
	 * @param groupCode 集团编码
	 * @param projectId 项目ID
	 * @param appId 应用ID
	 * @param userId 用户ID
	 * @param criteria 查询条件
	 * @return 类型定义
	 */
	@PostMapping("/rwd/def/class")
	CommonResult<List<ObjectNode>> queryObjectType(
			@RequestParam("groupCode") String groupCode,
			@RequestParam("projectId") String projectId,
			@RequestParam("appId") String appId,
			@RequestParam("userId") String userId,
			@RequestBody QueryCriteria criteria);

	@PostMapping("/rwd/def/funcid")
	CommonResult<List<ObjectNode>> queryFunc(
			@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 criteria: 查询条件
	 * @return 边类型数组
	 */
	@PostMapping("/rwd/def/rel/query")
	CommonResult<List<RelationDefine>> queryRelDef(@RequestParam("groupCode") String groupCode,
											 @RequestParam("projectId") String projectId,
											 @RequestParam("appId") String appId,
											 @RequestParam("userId") String userId,
											 @RequestBody QueryCriteria criteria);

	@PostMapping("/rwd/def/graph/query")
	CommonResult<List<GraphDefine>> queryGraphDef(@RequestParam("groupCode") String groupCode,
														 @RequestParam("projectId") String projectId,
														 @RequestParam("appId") String appId,
														 @RequestParam("userId") String userId,
														 @RequestBody QueryCriteria criteria);

	/**
	 * 查询关系
	 */
	@PostMapping({"/rwd/instance/relation/query"})
	CommonResult<List<ObjectNode>> queryRelation(@RequestParam("groupCode") String groupCode,
										 @RequestParam("projectId") String projectId,
										 @RequestParam("appId") String appId,
										 @RequestParam("userId") String userId,
										 @RequestBody QueryCriteria criteria);
}
