1、Unknown property "discount" in result type TestMixBO. Did you mean "null"?可能有以种原因:
BO类中属性名和setter/getter方法名称不匹配,这个一般是由人工修改引起的;
BO类中属性名和setter/getter方法名称不匹配,这个一般是由人工修改引起的;
@Builder、@AllArgsConstructor
非空验证时可以不指定@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)属性,直接使用@Mapper
原因是proto会把repeat修饰的变量后面默认给加上List后缀。所以映射时需特殊指定一下,如下:
- List<WorkflowDto> toDtos(List<WorkflowBo> var1);
-
- @Mapping(source = "children", target = "childrenList")
- WorkflowDto toDto(WorkflowBo var1);
- @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
-
- @Data
- public static class StudyDateRange implements Serializable {
- @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
- @DateTimeFormat(pattern = "yyyy-MM-dd")
- private Date start;
- @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
- @DateTimeFormat(pattern = "yyyy-MM-dd")
- private Date end;
- }
- //这主要是时区问题引起的
- @Mapping(target = "createdAt" , expression = "java(MapStructMapperUtil.dateToLocalDate(var1.getCtime()))" )
- @AfterMapping
- default void setLicenseActivationInfoBo(@MappingTarget LicenseActivationRecordBo bo, ActivationRecordEntity var1) {
- List<LicenseActivationInfoBo> activationInfo = JSONUtil.toList(var1.getActivationInfo(), LicenseActivationInfoBo.class);
- int accountTotal = 0;
- for(LicenseActivationInfoBo item: activationInfo) {
- accountTotal += item.getAccountLimit();
- }
- bo.setAccountLimit(accountTotal);
- bo.setActivationInfo(activationInfo);
- }
- message MyMessage {
- //定义一个枚举
- enum DataType {
- StudentType = 0;
- WorkerType = 1;
- }
- //用data_type标识传的是那一个枚举
- DataType data_type = 1;
- //标示每次枚举类型最多只能出现其中的一个 节省空间
- oneof dataBody {
- Student student = 2;
- Worker worker = 3;
- }
-
- }