package com.jeesharp.business.modules.finance.invoice.convert;

import com.jeesharp.business.modules.finance.invoice.dto.MemberInvoiceTitleSaveDTO;
import com.jeesharp.business.modules.finance.invoice.entity.MemberInvoiceTitle;
import com.jeesharp.business.modules.finance.invoice.enums.InvoiceTitleTypeEnum;
import com.jeesharp.business.modules.finance.invoice.vo.MemberInvoiceTitleInfoVO;
import com.jeesharp.business.modules.finance.invoice.vo.MemberInvoiceTitleListVO;
import com.jeesharp.business.modules.finance.invoice.vo.MemberInvoiceTitleQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * 发票抬头 MapStruct 转换器。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@Mapper
public interface MemberInvoiceTitleConvert extends BasePojoConvert<MemberInvoiceTitle, MemberInvoiceTitleSaveDTO,
        MemberInvoiceTitleInfoVO, MemberInvoiceTitleListVO, MemberInvoiceTitleQueryVO> {

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

    @Mapping(target = "titleTypeName", source = "titleType", qualifiedByName = "titleTypeToName")
    @Override
    MemberInvoiceTitleInfoVO toInfoVO(MemberInvoiceTitle entity);

    @Mapping(target = "titleTypeName", source = "titleType", qualifiedByName = "titleTypeToName")
    MemberInvoiceTitleListVO toListSingleVO(MemberInvoiceTitle entity);

    @Named("titleTypeToName")
    default String titleTypeToName(String titleType) {
        return InvoiceTitleTypeEnum.getDescByValue(titleType);
    }
}
