package com.seer.teach.pay.api.convert;

import com.seer.teach.common.enums.pay.PayOrderSourceEnum;
import com.seer.teach.pay.api.order.dto.PayOrderCreateReqDTO;
import com.seer.teach.pay.entity.PayOrderEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PayOrderConvert {

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

    @Mapping(source = "channelId", target = "channelId")
    @Mapping(source = "channelCode", target = "channelCode")
    @Mapping(source = "orderSourceEnum", target = "orderSource")
    PayOrderEntity convertOne(PayOrderCreateReqDTO reqDTO);


    default Integer mapOrderSourceEnum(PayOrderSourceEnum sourceEnum) {
        if (sourceEnum == null) {
            return null;
        }
        return sourceEnum.getCode();
    }
}