package com.zfire.mall.manager.convert;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zfire.mall.manager.bean.config.*;
import com.zfire.mall.manager.plus.entity.PartyAInfo;
import org.mapstruct.Context;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.Map;

/**
 * @author qinrongjun
 * @description
 * @date 2023/7/26 14:24 星期三
 */
@Mapper(config = CommonMapperConfig.class)
public interface FirstPartyCustomerManagementConvert {
    FirstPartyCustomerManagementConvert INSTANCE = Mappers.getMapper(FirstPartyCustomerManagementConvert.class);

    @Mapping(target = "provinceName", expression = "java(regionNameByIdMap.get(var0.getProvinceRegionId()))")
    @Mapping(target = "cityName", expression = "java(regionNameByIdMap.get(var0.getCityRegionId()))")
    @Mapping(target = "areaName", expression = "java(regionNameByIdMap.get(var0.getAreaId()))")
    @Mapping(target = "createName", source = "username")
    PartyAInfo toDO(FirstPartyCustomerManagementAddParam var0,String username, @Context Map<Long, String> regionNameByIdMap);

    @Mapping(target = "provinceName", expression = "java(regionNameByIdMap.get(var0.getProvinceRegionId()))")
    @Mapping(target = "cityName", expression = "java(regionNameByIdMap.get(var0.getCityRegionId()))")
    @Mapping(target = "areaName", expression = "java(regionNameByIdMap.get(var0.getAreaId()))")
    @Mapping(target = "updateName", source = "username")
    PartyAInfo toDO(FirstPartyCustomerManagementEditParam var0,String username, @Context Map<Long, String> regionNameByIdMap);

    FirstPartyCustomerManagementDetailVO toVO(PartyAInfo var0);

    @Mapping(target = "tradeParentName", expression = "java(tradeNameByIdMap.get(var0.getTradeParentId()))")
    @Mapping(target = "tradeName", expression = "java(tradeNameByIdMap.get(var0.getTradeId()))")
    FirstPartyCustomerManagementListVO toListVO(PartyAInfo var0, @Context Map<String, String> tradeNameByIdMap);

    Page<FirstPartyCustomerManagementListVO> toPageVO(IPage<PartyAInfo> var0, @Context Map<String, String> tradeNameByIdMap);
}