package com.jeesharp.business.modules.marketing.couponVerifyLog.convert;

import com.jeesharp.business.modules.marketing.couponVerifyLog.dto.MemberCouponVerifyLogSaveDTO;
import com.jeesharp.business.modules.marketing.couponVerifyLog.entity.MemberCouponVerifyLog;
import com.jeesharp.business.modules.marketing.couponVerifyLog.enums.CouponVerifyTypeEnum;
import com.jeesharp.business.modules.marketing.couponVerifyLog.vo.MemberCouponVerifyLogExportVO;
import com.jeesharp.business.modules.marketing.couponVerifyLog.vo.MemberCouponVerifyLogInfoVO;
import com.jeesharp.business.modules.marketing.couponVerifyLog.vo.MemberCouponVerifyLogListVO;
import com.jeesharp.business.modules.marketing.couponVerifyLog.vo.MemberCouponVerifyLogQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 核销流水 MapStruct 转换器。
 *
 * @author jeesharp
 * @since 2026-06-25
 */
@Mapper
public interface MemberCouponVerifyLogConvert extends
        BasePojoConvert<MemberCouponVerifyLog, MemberCouponVerifyLogSaveDTO, MemberCouponVerifyLogInfoVO, MemberCouponVerifyLogListVO, MemberCouponVerifyLogQueryVO> {

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

    @Override
    @Named("couponVerifyLogToList")
    @Mapping(target = "verifyTypeName", source = "verifyType", qualifiedByName = "verifyTypeToName")
    @Mapping(target = "memberNo", ignore = true)
    @Mapping(target = "memberNickname", ignore = true)
    @Mapping(target = "memberMobile", ignore = true)
    MemberCouponVerifyLogListVO toListSingleVO(MemberCouponVerifyLog entity);

    @Override
    @Named("couponVerifyLogToInfo")
    @Mapping(target = "verifyTypeName", source = "verifyType", qualifiedByName = "verifyTypeToName")
    @Mapping(target = "memberNo", ignore = true)
    @Mapping(target = "memberNickname", ignore = true)
    @Mapping(target = "memberMobile", ignore = true)
    MemberCouponVerifyLogInfoVO toInfoVO(MemberCouponVerifyLog entity);

    @Override
    @IterableMapping(qualifiedByName = "couponVerifyLogToList")
    List<MemberCouponVerifyLogListVO> toListVO(List<MemberCouponVerifyLog> list);

    @Override
    @IterableMapping(qualifiedByName = "couponVerifyLogToInfo")
    List<MemberCouponVerifyLogInfoVO> toInfoListVO(List<MemberCouponVerifyLog> list);

    @Mapping(target = "verifyTypeName", source = "verifyType", qualifiedByName = "verifyTypeToName")
    @Mapping(target = "memberId", source = "memberId")
    @Mapping(target = "memberNo", ignore = true)
    @Mapping(target = "memberNickname", ignore = true)
    @Mapping(target = "memberMobile", ignore = true)
    MemberCouponVerifyLogExportVO toExportVO(MemberCouponVerifyLog entity);

    List<MemberCouponVerifyLogExportVO> toExportVOList(List<MemberCouponVerifyLog> list);

    @Named("verifyTypeToName")
    default String verifyTypeToName(String verifyType) {
        return CouponVerifyTypeEnum.getDescByValue(verifyType);
    }
}
