mapstruct 枚举类型转文字(数字转文字)

@Mapper(imports = {PaymentWayEnum.class, RechargeEnum.class})
public interface RechargeLogTransfer {
    @Mappings({
        @Mapping(target = "paymentWayStr", expression = "java(PaymentWayEnum.getRemark(rechargeLog.getPaymentWay().toString()))"),
      @Mapping(target = "typeStr", expression = "java(RechargeEnum.getMsg(rechargeLog.getType()))"),
    })
    RechargeLogRes toRechargeLogRes(RechargeLog rechargeLog);
}
讨论数量: 1

欢迎加入Java程序员 和一起讨论2000人一起讨论 Q群 189195811

3周前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!