package com.persagy.dmp.delivery.client;

import cn.hutool.extra.spring.SpringUtil;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.define.entity.RelationDefine;
import com.persagy.dmp.delivery.entity.RelationDefineCollect;

import java.util.List;

/**
 * 关系交付范围Client门面
 * @author Charlie Yu
 * @date 2021-05-15
 */
public class DigitalRelationDefineCollectFacade {

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

    /**
     * 查询关系交付范围
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param criteria 查询条件
     * @return 关系交付范围对象集合
     */
    public static List<RelationDefineCollect> query(String groupCode, String projectId, String appId, String userId, QueryCriteria criteria) {
        CommonResult<List<RelationDefineCollect>> result = client.query(groupCode, projectId, appId, userId, criteria);
        return ResultHelper.getContent(result);
    }

    /**
     * 查询关系交付范围-原样返回结果
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param criteria 查询条件
     * @return 关系交付范围对象集合
     */
    public static CommonResult<List<RelationDefineCollect>> queryPrototype(String groupCode, String projectId, String appId, String userId, QueryCriteria criteria) {
        return client.query(groupCode, projectId, appId, userId, criteria);
    }
    /**
     * 创建关系交付范围
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param vo 关系交付范围对象
     * @return 关系交付范围对象
     */
    public static RelationDefineCollect create(String groupCode, String projectId, String appId, String userId, RelationDefineCollect vo) {
        CommonResult<RelationDefineCollect> commonResult = client.create(groupCode, projectId, appId, userId, vo);
        return commonResult.getData();
    }
    /**
     * 更新关系交付范围
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param vo 关系交付范围对象
     * @return 关系交付范围对象
     */
    public static RelationDefineCollect update(String groupCode, String projectId, String appId, String userId, RelationDefineCollect vo) {
        CommonResult<RelationDefineCollect> commonResult = client.update(groupCode, projectId, appId, userId, vo);
        return commonResult.getData();
    }
    /**
     * 删除关系交付范围
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param id 关系交付范围对象id
     * @return 关系交付范围对象
     */
    public static RelationDefineCollect delete(String groupCode, String projectId, String appId, String userId, String id) {
        CommonResult<RelationDefineCollect> commonResult = client.delete(groupCode, projectId, appId, userId, id);
        return commonResult.getData();
    }
}
