package com.jeesharp.business.modules.member.convert;

import com.jeesharp.business.modules.member.dto.MemberVipSaveDTO;
import com.jeesharp.business.modules.member.entity.MemberVip;
import com.jeesharp.business.modules.member.enums.MemberVipStatusEnum;
import com.jeesharp.business.modules.member.vo.MemberVipInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * 会员付费开通记录转换器
 *
 * @author jeesharp
 * @version 2026-03-19
 */
@Mapper
public interface MemberVipConvert {

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

    @Mapping(target = "memberNo", ignore = true)
    @Mapping(target = "memberNickname", ignore = true)
    @Mapping(target = "levelName", ignore = true)
    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    MemberVipInfoVO toInfoVO(MemberVip entity);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "status", ignore = true)
    @Mapping(target = "createById", ignore = true)
    @Mapping(target = "createDate", ignore = true)
    @Mapping(target = "updateById", ignore = true)
    @Mapping(target = "updateDate", ignore = true)
    @Mapping(target = "delFlag", ignore = true)
    @Mapping(target = "remarks", source = "remarks")
    @Mapping(target = "tenantCode", ignore = true)
    @Mapping(target = "tenantId", ignore = true)
    MemberVip fromSaveDTO(MemberVipSaveDTO dto);

    @Named("statusToName")
    default String statusToName(Integer status) {
        return MemberVipStatusEnum.getDescByValue(status);
    }
}
