package com.seer.teach.pay.admin.withdrawal.convert;

import com.seer.teach.pay.admin.withdrawal.controller.request.PayMerchantBankAccountReq;
import com.seer.teach.pay.admin.withdrawal.controller.response.PayMerchantBankAccountResp;
import com.seer.teach.pay.entity.PayMerchantBankAccountEntity;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface PayMerchantBankAccountConvert {

    PayMerchantBankAccountConvert INSTANCE = Mappers.getMapper(PayMerchantBankAccountConvert.class);

    /**
     * 将请求对象转换为实体对象
     * @param req 请求对象
     * @return 实体对象
     */
    PayMerchantBankAccountEntity convertReqToEntity(PayMerchantBankAccountReq req);

    /**
     * 将请求对象更新到实体对象
     * @param req 请求对象
     * @param entity 实体对象
     */
    @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
    void updateEntityFromReq(PayMerchantBankAccountReq req, @MappingTarget PayMerchantBankAccountEntity entity);

    /**
     * 将实体对象转换为响应对象
     * @param entity 实体对象
     * @return 响应对象
     */
    PayMerchantBankAccountResp convertEntityToResp(PayMerchantBankAccountEntity entity);

    /**
     * 将实体对象列表转换为响应对象列表
     * @param entityList 实体对象列表
     * @return 响应对象列表
     */
    List<PayMerchantBankAccountResp> convertEntityListToRespList(List<PayMerchantBankAccountEntity> entityList);
}