YqMerchantConfigDTOConvert.java 4.25 KB
package cn.com.glsx.dj.smartcarlife.convert;

import cn.com.glsx.dj.smartcarlife.dto.YqMerchantConfigDTO;
import cn.com.glsx.dj.smartcarlife.dto.YqMerchantConfigUpdatePartnerMerchantReqDTO;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigSearchRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigUpdatePartnerMerchantRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigUpdateRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.serviceMerchant.ServiceMerchantRelateQrcodeRequest;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigDetailResponse;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigPageResponse;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigUpdateResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface YqMerchantConfigDTOConvert {
    YqMerchantConfigDTOConvert INSTANCE = Mappers.getMapper(YqMerchantConfigDTOConvert.class);

    @Mappings({
         @Mapping(source = "yqMerchantId",target = "merchantId"),

         @Mapping(target = "supportPayType", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getSupportPayType(sourceEntity.getSupportPayTypes()))"),
         @Mapping(source = "businessModel",target = "businessModel")
    })
    YqMerchantConfigDTO fromYqMerchantConfigUpdateRequest(YqMerchantConfigUpdateRequest sourceEntity);

    /**
     * 转换更新主服务商请求
     *
     * @param sourceEntity ROP请求
     * @return 更新主服务商请求DTO
     */
    YqMerchantConfigUpdatePartnerMerchantReqDTO fromYqMerchantConfigUpdatePartnerMerchantRequest(
            YqMerchantConfigUpdatePartnerMerchantRequest sourceEntity);

    @Mappings({
         @Mapping(source = "merchantId",target = "yqMerchantId"),
         @Mapping(target = "supportPayTypes", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getSupportPayTypes(sourceEntity.getSupportPayType()))")
    })
    YqMerchantConfigUpdateResponse toYqMerchantConfigUpdateResponse(YqMerchantConfigDTO sourceEntity);

    @Mappings({
         @Mapping(source = "merchantId",target = "yqMerchantId"),
         @Mapping(source = "workWechatQrcode",target = "workWechatQrcode"),
         @Mapping(target = "supportPayTypes", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getSupportPayTypes(sourceEntity.getSupportPayType()))"),
         @Mapping(source = "qrcodeType", target = "qrcodeType"),
         @Mapping(target = "loginControlList", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getloginControlList(sourceEntity.getLoginControl()))")
    })
    YqMerchantConfigDetailResponse toYqMerchantConfigDetailResponse(YqMerchantConfigDTO sourceEntity);

    @Mappings({
         @Mapping(source = "merchantId",target = "yqMerchantId"),
         @Mapping(source = "yqMerchant.merchantName",target = "yqMerchantName"),
         @Mapping(source = "yqMerchant.accountName",target = "accountName"),
         @Mapping(source = "yqMerchant.merchantType",target = "merchantType"),
         @Mapping(source = "yqMerchant.paymentChannelId",target = "paymentChannelId"),
         @Mapping(target = "supportPayTypes", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getSupportPayTypes(sourceEntity.getSupportPayType()))")
    })
    YqMerchantConfigPageResponse toYqMerchantConfigPageResponse(YqMerchantConfigDTO sourceEntity);

    @Mappings({
            @Mapping(source = "yqMerchantId",target = "merchantId"),
            @Mapping(source = "yqMerchantName",target = "merchantName")
    })
    YqMerchantConfigDTO fromYqMerchantConfigSearchRequest(YqMerchantConfigSearchRequest sourceEntity);


    @Mappings({
            @Mapping(source = "yqMerchantId",target = "merchantId"),
            @Mapping(source = "imgUrl",target = "workWechatQrcode"),
            @Mapping(source = "qrcodeType", target = "qrcodeType")
    })
    YqMerchantConfigDTO fromYqMerchantConfigServiceMerchantRelateQrcodeRequest(ServiceMerchantRelateQrcodeRequest sourceEntity);


}