package cn.pluss.platform.converter;

import cn.pluss.platform.dto.*;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.vo.*;
import com.aliyuncs.geoip.model.v20200101.DescribeIpv4LocationResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

/**
 * @author djh
 */
@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface Converter {

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

    /**
     * MerchantCashPlaceStaff转换为VO
     *
     * @param cashPlaceStaff MerchantCashPlaceStaff对象
     * @return
     */
    MerchantCashPlaceStaffVO toVO(MerchantCashPlaceStaff cashPlaceStaff);

    /**
     * MerchantChannelStatus转换为VO
     *
     * @param entity MerchantChannelStatus对象
     * @return
     */
    ChannelStatusVO toVO(MerchantChannelStatus entity);

    RegionReflect toEntity(RegionReflectDTO dto);

    MerchantRateNewVO toVO(MerchantRateNew merchantRateNew);

    MerchantRateNew trans(MerchantRateNewRecord rateNewRecord);

    MerchantRateNewRecord trans(MerchantRateNew rateNew);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void cp(MerchantRateNewRecord source, @MappingTarget MerchantRateNew target);

    MerchantRateNewRecordVO toVO(MerchantRateNewRecord rateNewRecord);

    AccountDTO toDTO(Account account);

    Account toEntity(AccountDTO accountDTO);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void cp(IdCard source, @MappingTarget IdCard target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void cp(BankCard source, @MappingTarget BankCard target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(Account source, @MappingTarget AccountDTO target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(AccountDTO source, @MappingTarget Account target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(BankInfoDTO source, @MappingTarget BankCard target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(UserApp source, @MappingTarget UserAppVO target);

    /**
     * dto转VO
     * @param accountDTO
     * @return
     */
    AccountVO toVO(AccountDTO accountDTO);

    /**
     * dto 转为 entity
     *
     * @param deviceStockDTO
     * @return
     */
    DeviceStock toEntity(DeviceStockDTO deviceStockDTO);

    /**
     * dto 转为 entity
     *
     * @param bankCardDTO
     * @return
     */
    BankCard toEntity(BankCardDTO bankCardDTO);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(IpLocationCache source, @MappingTarget DescribeIpv4LocationResponse target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void cp(DescribeIpv4LocationResponse source, @MappingTarget IpLocationCache target);

    DeviceStockVO toVO(DeviceStock entity);

    DeviceDetailVO toVO(DeviceDetail entity);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    @Mapping(target = "id", ignore = true)
    void cp(UserVoice source, @MappingTarget UserVoice target);

    /**
     * 参数复制
     * @param source    源数据对象
     * @param target    目标对象
     */
    void cp(MercTradeDataDTO source, @MappingTarget MercTradeDataDTO target);

    /**
     * 参数复制
     * @param entity
     * @return
     */
    JftReceiptInfoVO toVO(JftReceiptInfo entity);

    @Mapping(target = "id", ignore = true)
    JftBankCard toJftData(BankCard bankCard);

    @Mapping(target = "id", ignore = true)
    JftMerchantRateRecord toRecord(JftMerchantRate entity);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void cp(JftMerchantRateRecord source, @MappingTarget JftMerchantRate target);

    @Mapping(target = "id", ignore = true)
    MercMemberSetVO toVO(MercMemberSet mercMemberSet);

    @Mapping(target = "id", ignore = true)
    JftMercBaseInfoVO toVO(JftMercBaseInfo jftMercBaseInfo);

    @Mapping(target = "id", ignore = true)
    JftMercPaymentChannelVO toVO(JftMercPaymentChannel jftMercPaymentChannel);
}
