java使用 MapStruct 的 Mapper 接口

42 阅读1分钟

用于将 MassQueryResult 对象转换为 OrgPartCostRsp 对象

@Mapper(componentModel = "spring") // 使用默认组件模型(Spring 环境下通常改为 "spring")
public interface OrgPartCostRspConvert {
    // MapStruct 生成的实现类实例
    OrgPartCostRspConvert instance = Mappers.getMapper(OrgPartCostRspConvert.class);
    @Mappings({
            @Mapping(source = "c1", target = "costTypeId"), // 将源对象的 c1 字段映射到目标对象的 costTypeId
            @Mapping(source = "c2", target = "costType"),
            @Mapping(source = "c3", target = "organizationId"),
            @Mapping(source = "c4", target = "segment1"),
            @Mapping(source = "c5", target = "itemCost"),
            @Mapping(source = "c6", target = "currencyCode"),
            @Mapping(source = "c8", target = "materialCost"),
            @Mapping(source = "c9", target = "ouId"),
            @Mapping(source = "c10", target = "lastUpdateDate"),
    })
    OrgPartCostRsp toOrgPartCostRsp(MassQueryResult result);
}