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

import com.jeesharp.business.modules.mall.dto.MallFirstOrderConfigSaveDTO;
import com.jeesharp.business.modules.mall.entity.MallFirstOrderConfig;
import com.jeesharp.business.modules.mall.vo.MallFirstOrderConfigInfoVO;
import com.jeesharp.business.modules.mall.vo.MallFirstOrderConfigListVO;
import com.jeesharp.business.modules.mall.vo.MallFirstOrderConfigQueryVO;
import com.jeesharp.business.modules.mall.enums.MallFirstOrderConfigStatusEnum;
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-02-05
 */
@Mapper
public interface MallFirstOrderConfigConvert extends BasePojoConvert<MallFirstOrderConfig, MallFirstOrderConfigSaveDTO, MallFirstOrderConfigInfoVO, MallFirstOrderConfigListVO, MallFirstOrderConfigQueryVO> {

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

    @Override
    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    MallFirstOrderConfigInfoVO toInfoVO(MallFirstOrderConfig entity);

    @Override
    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    MallFirstOrderConfigListVO toListSingleVO(MallFirstOrderConfig entity);

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