package com.persagy.dmp.migrate.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.rwd.migrate.entity.SyncData;

import java.util.List;

/**
 * @author lvxianyun
 * @title: DigitalMigrateLogFacade
 * @projectName digital-twin
 * @description: 数据迁移门面
 * @date 2021/12/20 19:05
 */
public class DigitalMigrateLogFacade {

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

    /**
     * 查询数据迁移日志
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param criteria: 请求参数
     * @return 对象数组
     */
    public static CommonResult<List<SyncData>> query(String groupCode, String projectId, String appId,
                                       String userId, QueryCriteria criteria) {
        CommonResult<List<SyncData>> result = client.query(groupCode, projectId, appId, userId, criteria);
        return result;
    }


    /**
     * 新增数据迁移日志-批量新增
     * @param groupCode: 集团编码
     * @param projectId: 项目ID
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param syncDataList: 新增对象集合
     * @return 对象数组
     */
    public static List<SyncData> create(String groupCode, String projectId, String appId,
                                             String userId, List<SyncData> syncDataList) {
        CommonResult<List<SyncData>> result = client.create(groupCode, projectId, appId, userId, syncDataList);
        return ResultHelper.getContent(result);
    }
}
