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

import com.jeesharp.business.modules.mall.dto.MallTagSaveDTO;
import com.jeesharp.business.modules.mall.entity.MallTag;
import com.jeesharp.business.modules.mall.enums.MallTagTypeEnum;
import com.jeesharp.business.modules.mall.vo.MallTagInfoVO;
import com.jeesharp.business.modules.mall.vo.MallTagListVO;
import com.jeesharp.business.modules.mall.vo.MallTagQueryVO;
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-04
 */
@Mapper
public interface MallTagConvert extends BasePojoConvert<MallTag, MallTagSaveDTO, MallTagInfoVO, MallTagListVO, MallTagQueryVO> {

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

    @Override
    @Mapping(target = "tagTypeName", source = "tagType", qualifiedByName = "tagTypeToName")
    MallTagInfoVO toInfoVO(MallTag entity);

    @Override
    @Mapping(target = "tagTypeName", source = "tagType", qualifiedByName = "tagTypeToName")
    MallTagListVO toListSingleVO(MallTag entity);

    @Named("tagTypeToName")
    default String tagTypeToName(Integer tagType) {
        return MallTagTypeEnum.getDescByValue(tagType);
    }
}
