问题在标题里。问题如下:我有两个类,一个扩展另一个。当我返回controller中的子类时,值转换为null。请不要害怕大量的领域。
控制器中的方法:
@GetMapping("/")
public List<? extends ProjectAreaBasic<?>> list(@PathVariable Project.Id projectId) {
return listViewProvider.findAllByProjectId(projectId);
}
儿童班:
import com.gramant.ooh.domain.utils.FieldCopier;
import io.thedocs.domain.Wrapper;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@Getter
@Slf4j
@NoArgsConstructor
public class ProjectArea<T> extends ProjectAreaBasic<T> {
protected BigDecimal productionGrossB;
protected BigDecimal productionNetB;
protected BigDecimal productionPrintRunGrossB;
protected BigDecimal productionPrintRunNetB;
protected BigDecimal purchaseGross;
protected BigDecimal purchaseNet;
protected BigDecimal installationGrossB;
protected BigDecimal installationNetB;
protected BigDecimal reinstallationGrossB;
protected BigDecimal reinstallationNetB;
protected TaxType taxInstallationB;
protected TaxType taxPrintB;
protected TaxType taxPurchase;
protected Integer technicalVolumeB;
protected BigDecimal totalGrossB;
protected BigDecimal totalNetB;
protected Provider.Id sellerId;
protected StatusAddress.Id statusAddressId;
@Builder(builderMethodName = "projectAreaBuilder")
public ProjectArea(Id id, OffsetDateTime addedAt, BigDecimal agentCommissionGross, BigDecimal agentCommissionNds, BigDecimal agentCommissionNet, Integer angle, Boolean angleUsage, BigDecimal blockDuration, String clientStatusComment, String comments, BigDecimal costGross, BigDecimal costNet, boolean isDeleted, LocalDate deliveryDate, OffsetDateTime deliveryUpdatedAt, BigDecimal discount, BigDecimal duration, String imageLink, BigDecimal installationGrossK, BigDecimal installationNetK, LocalDate installationDate, String layoutImage, String layoutNumber, String map, Integer mapNumber, boolean isMonth1, boolean isMonth2, boolean isMonth3, boolean isMonth4, boolean isMonth5, boolean isMonth6, boolean isMonth7, boolean isMonth8, boolean isMonth9, boolean isMonth10, boolean isMonth11, boolean isMonth12, Short monthNumber, BigDecimal nds, Integer number, String ots, boolean isPacket, Integer penaltyPeriod, Integer perBlockNumber, Integer perDayNumber, Integer perPeriodNumber, BigDecimal priceGross, BigDecimal priceNet, BigDecimal productionAkGross, TaxType productionAkNds, BigDecimal productionAkNet, BigDecimal productionCostGrossK, BigDecimal productionCostNetK, BigDecimal productionPrintRunGrossK, BigDecimal productionPrintRunNetK, BigDecimal reinstallationGrossK, BigDecimal reinstallationNetK, String requirements, LocalDate rimInstallationDate, OffsetDateTime rimInstallationUpdatedAt, Integer rollerNumber, String screenHours, String status, TaxType taxCost, TaxType taxInstallationK, TaxType taxPrintK, Integer technicalVolumeK, BigDecimal totalGrossK, BigDecimal totalNetK, boolean isVisibleAll, Integer year, Area.Id areaId, Attachment.Id commentsAttachmentId, Manager.Id deliveryManagerId, Manager.Id installationManagerId, Material.Id materialId, Mediatype.Id mediaId, City.Id printingCityId, Project.Id projectId, Region.Id regionId, Attachment.Id requirementsAttachmentId, StatusClient.Id statusClientId, User.Id userId, T extend, BigDecimal productionGrossB, BigDecimal productionNetB, BigDecimal productionPrintRunGrossB, BigDecimal productionPrintRunNetB, BigDecimal purchaseGross, BigDecimal purchaseNet, BigDecimal installationGrossB, BigDecimal installationNetB, BigDecimal reinstallationGrossB, BigDecimal reinstallationNetB, TaxType taxInstallationB, TaxType taxPrintB, TaxType taxPurchase, Integer technicalVolumeB, BigDecimal totalGrossB, BigDecimal totalNetB, Provider.Id sellerId, StatusAddress.Id statusAddressId) {
super(id, addedAt, agentCommissionGross, agentCommissionNds, agentCommissionNet, angle, angleUsage,
blockDuration, clientStatusComment, comments, costGross, costNet, isDeleted, deliveryDate, deliveryUpdatedAt,
discount, duration, imageLink, installationGrossK, installationNetK, installationDate, layoutImage, layoutNumber,
map, mapNumber, isMonth1, isMonth2, isMonth3, isMonth4, isMonth5, isMonth6, isMonth7, isMonth8, isMonth9, isMonth10, isMonth11,
isMonth12, monthNumber, nds, number, ots, isPacket, penaltyPeriod, perBlockNumber, perDayNumber, perPeriodNumber, priceGross,
priceNet, productionAkGross, productionAkNds, productionAkNet, productionCostGrossK, productionCostNetK, productionPrintRunGrossK,
productionPrintRunNetK, reinstallationGrossK, reinstallationNetK, requirements, rimInstallationDate, rimInstallationUpdatedAt,
rollerNumber, screenHours, status, taxCost, taxInstallationK, taxPrintK, technicalVolumeK, totalGrossK, totalNetK, isVisibleAll,
year, areaId, commentsAttachmentId, deliveryManagerId, installationManagerId, materialId, mediaId, printingCityId, projectId,
regionId, requirementsAttachmentId, statusClientId, userId, extend);
this.regionId = regionId;
this.statusClientId = statusClientId;
this.productionGrossB = productionGrossB;
this.productionNetB = productionNetB;
this.productionPrintRunGrossB = productionPrintRunGrossB;
this.productionPrintRunNetB = productionPrintRunNetB;
this.purchaseGross = purchaseGross;
this.purchaseNet = purchaseNet;
this.installationGrossB = installationGrossB;
this.installationNetB = installationNetB;
this.reinstallationGrossB = reinstallationGrossB;
this.reinstallationNetB = reinstallationNetB;
this.taxInstallationB = taxInstallationB;
this.taxPrintB = taxPrintB;
this.taxPurchase = taxPurchase;
this.technicalVolumeB = technicalVolumeB;
this.totalGrossB = totalGrossB;
this.totalNetB = totalNetB;
this.sellerId = sellerId;
this.statusAddressId = statusAddressId;
}
@SneakyThrows
public ProjectArea(ProjectArea<?> item, T extend) {
FieldCopier.instance().copyFieldsFromSuper(this, item);
this.extend = extend;
}
public static class Id extends Wrapper.Int {
public Id(String value) {
super(value);
}
public Id(int value) {
super(value);
}
public Id() {
}
}
和父类:
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@Getter
@EqualsAndHashCode(exclude = "extend")
@Builder(builderMethodName = "projectAreaBasicBuilder")
@AllArgsConstructor
@NoArgsConstructor
public class ProjectAreaBasic<T> {
protected ProjectArea.Id id;
protected OffsetDateTime addedAt;
protected BigDecimal agentCommissionGross;
protected BigDecimal agentCommissionNds;
protected BigDecimal agentCommissionNet;
protected Integer angle;
protected Boolean angleUsage;
protected BigDecimal blockDuration;
protected String clientStatusComment;
protected String comments;
protected BigDecimal costGross;
protected BigDecimal costNet;
protected boolean isDeleted;
protected LocalDate deliveryDate;
protected OffsetDateTime deliveryUpdatedAt;
protected BigDecimal discount;
protected BigDecimal duration;
protected String imageLink;
protected BigDecimal installationGrossK;
protected BigDecimal installationNetK;
protected LocalDate installationDate;
protected String layoutImage;
protected String layoutNumber;
protected String map;
protected Integer mapNumber;
protected boolean isMonth1;
protected boolean isMonth2;
protected boolean isMonth3;
protected boolean isMonth4;
protected boolean isMonth5;
protected boolean isMonth6;
protected boolean isMonth7;
protected boolean isMonth8;
protected boolean isMonth9;
protected boolean isMonth10;
protected boolean isMonth11;
protected boolean isMonth12;
protected Short monthNumber;
protected BigDecimal nds;
protected Integer number;
protected String ots;
protected boolean isPacket;
protected Integer penaltyPeriod;
protected Integer perBlockNumber;
protected Integer perDayNumber;
protected Integer perPeriodNumber;
protected BigDecimal priceGross;
protected BigDecimal priceNet;
protected BigDecimal productionAkGross;
protected TaxType productionAkNds;
protected BigDecimal productionAkNet;
protected BigDecimal productionCostGrossK;
protected BigDecimal productionCostNetK;
protected BigDecimal productionPrintRunGrossK;
protected BigDecimal productionPrintRunNetK;
protected BigDecimal reinstallationGrossK;
protected BigDecimal reinstallationNetK;
protected String requirements;
protected LocalDate rimInstallationDate;
protected OffsetDateTime rimInstallationUpdatedAt;
protected Integer rollerNumber;
protected String screenHours;
protected String status;
protected TaxType taxCost;
protected TaxType taxInstallationK;
protected TaxType taxPrintK;
protected Integer technicalVolumeK;
protected BigDecimal totalGrossK;
protected BigDecimal totalNetK;
protected boolean isVisibleAll;
protected Integer year;
protected Area.Id areaId;
protected Attachment.Id commentsAttachmentId;
protected Manager.Id deliveryManagerId;
protected Manager.Id installationManagerId;
protected Material.Id materialId;
protected Mediatype.Id mediaId;
protected City.Id printingCityId;
protected Project.Id projectId;
protected Region.Id regionId;
protected Attachment.Id requirementsAttachmentId;
protected StatusClient.Id statusClientId;
protected User.Id userId;
protected T extend;
@SneakyThrows
public ProjectAreaBasic(ProjectAreaBasic<?> item, T extend) {
FieldCopier.instance().copyFieldsFromSuper(this, item);
this.extend = extend;
}
结果如下:
addedAt: null
agentCommissionGross: null
agentCommissionNds: null
agentCommissionNet: null
angle: null
angleUsage: null
areaId: null
blockDuration: null
clientStatusComment: null
comments: null
commentsAttachmentId: null
costGross: null
costNet: null
deleted: false
deliveryDate: null
deliveryManagerId: null
deliveryUpdatedAt: null
discount: null
duration: null
extend: {,…}
area: {id: 72870, addedAt: "2018-10-09T21:06:50.9061+03:00", address: "Рабоче-Крестьянская ул., 7",…}
brand: {id: 1602, name: "1Xbet"}
material: {id: 4, name: "самоклейка", used: true}
printingCity: null
projectAreaArts: [{id: 195, projectAreaId: 811, createdAt: "2020-12-03T16:58:20.932147+03:00", deletedAt: null,…}]
region: {id: 11, name: "Волгоградская область"}
seller: {id: 6876, name: "Дрим"}
statusAddress: null
statusClient: {id: 10, name: "Подтвержден", used: true}
tags: []
id: null
imageLink: null
installationDate: null
installationGrossB: null
installationGrossK: null
installationManagerId: null
installationNetB: null
installationNetK: null
layoutImage: null
layoutNumber: null
map: null
mapNumber: null
materialId: null
mediaId: null
month1: false
month2: false
month3: false
month4: false
month5: false
month6: false
month7: false
month8: false
month9: false
month10: false
month11: false
month12: false
monthNumber: null
nds: null
number: null
ots: null
packet: false
penaltyPeriod: null
perBlockNumber: null
perDayNumber: null
perPeriodNumber: null
priceGross: null
priceNet: null
printingCityId: null
productionAkGross: null
productionAkNds: null
productionAkNet: null
productionCostGrossK: null
productionCostNetK: null
productionGrossB: null
productionNetB: null
productionPrintRunGrossB: null
productionPrintRunGrossK: null
productionPrintRunNetB: null
productionPrintRunNetK: null
projectId: null
purchaseGross: null
purchaseNet: null
regionId: null
reinstallationGrossB: null
reinstallationGrossK: null
reinstallationNetB: null
reinstallationNetK: null
requirements: null
requirementsAttachmentId: null
rimInstallationDate: null
rimInstallationUpdatedAt: null
rollerNumber: null
screenHours: null
sellerId: 6876
status: null
statusAddressId: 100
statusClientId: null
taxCost: null
taxInstallationB: null
taxInstallationK: null
taxPrintB: null
taxPrintK: null
taxPurchase: null
technicalVolumeB: null
technicalVolumeK: null
totalGrossB: null
totalGrossK: null
totalNetB: null
totalNetK: null
userId: null
visibleAll: false
year: null
暂无答案!
目前还没有任何答案,快来回答吧!