package cn.axzo.msg.center.message.service.gateway.impl;

import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.meepo.api.definition.bankcard.query.BankCardApi;
import cn.axzo.meepo.api.definition.bankcard.query.dto.response.WorkerBankCardApiRes;
import cn.axzo.msg.center.common.utils.BizAssertions;
import cn.axzo.msg.center.message.service.gateway.BackCardApiGateway;
import cn.azxo.framework.common.logger.MethodAroundLog;
import cn.azxo.framework.common.utils.LogUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @ClassName BackCardApiGateway
 * @Author zhangRan
 * @Date 2023/6/25 10:58
 * @Description 银行卡
 **/

@Component
@Slf4j
public class BackCardApiGatewayImpl implements BackCardApiGateway {

    @Autowired
    private BankCardApi bankCardApi;

    @MethodAroundLog(source = "msg-center", target = "meepo", value = "用户银行卡列表")
    public List<WorkerBankCardApiRes> getPersonBackCard(List<Long> personIds) {
        log.info("用户银行卡列表 用户id = {}", JSONUtil.toJsonStr(personIds));
        List<WorkerBankCardApiRes> result = Collections.emptyList();
        try {
            ApiResult<List<WorkerBankCardApiRes>> response = bankCardApi.batchGetBankCardByPersonId(personIds);
            log.info("用户银行卡列表 personIds={}, result={}", JSONUtil.toJsonStr(personIds), JSONUtil.toJsonStr(response));
            return BizAssertions.assertResponse(response);
        } catch (Exception ex) {
            log.error("请求 meepo【用户银行卡列表】 发生异常", ex);
        }
        return result;
    }


}
