package com.persagy.dmp.codetable.client;

import cn.hutool.extra.spring.SpringUtil;
import com.persagy.dmp.basic.dto.RequestData;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.codetable.entity.CodeTableData;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.define.client.DigitalDefineClient;
import com.persagy.dmp.define.entity.ObjectTypeDefine;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 数据字典Client门面
 * @author Charlie Yu
 * @date 2021-05-15
 */
public class CodeTableDataFacade {

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

    /**
     * 根据码表类型查询所有字典数据
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param typeCode 码表类型编码
     * @return List<CodeTableData>
     */
    public static List<CodeTableData> queryCodeTableDetailListByTypeCode(
            String groupCode, String projectId, String appId, String userId, String typeCode){
        CommonResult<List<CodeTableData>> result = client.queryCodeTableDetailListByTypeCode(groupCode, projectId, appId, userId, typeCode);
        return ResultHelper.getContent(result);
    }

    /**
     * 根据码表类型及码表数据code查询字典详情
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param requestData 请求参数
     * @return List<CodeTableData>
     */
    public static List<CodeTableData> queryCodeTableDatasByTypeCodeAndCodes(
            String groupCode, String projectId, String appId, String userId, RequestData requestData){
        CommonResult<List<CodeTableData>> result = client
                .queryCodeTableDatasByTypeCodeAndCodes(groupCode, projectId, appId, userId, requestData);
        return ResultHelper.getContent(result);
    }
    /**
     * 根据码表类型及父码表code查询其下的码表数据
     * @param groupCode 集团编码
     * @param projectId 项目ID
     * @param appId 应用ID
     * @param userId 用户ID
     * @param requestData 请求参数
     * @return List<CodeTableData>
     */
    public static List<CodeTableData> queryCodeTableDatasByParentCode(
            String groupCode, String projectId, String appId, String userId, RequestData requestData){
        CommonResult<List<CodeTableData>> result = client
                .queryCodeTableDatasByParentCode(groupCode, projectId, appId, userId, requestData);
        return ResultHelper.getContent(result);
    }
}
