mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 19:06:49 +08:00
fix: 课程列表dao层报错修正
排查空指针问题修正
This commit is contained in:
@@ -134,8 +134,12 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
List<CoursePageVo> coursePageVos = new ArrayList<>();
|
List<CoursePageVo> coursePageVos = new ArrayList<>();
|
||||||
for (Object[] row : resultList) {
|
for (Object[] row : resultList) {
|
||||||
CoursePageVo vo = new CoursePageVo();
|
CoursePageVo vo = new CoursePageVo();
|
||||||
|
// 防止BigInteger为null的情况
|
||||||
BigInteger id = (BigInteger) row[0];
|
BigInteger id = (BigInteger) row[0];
|
||||||
vo.setId(id.toString());
|
if (id != null) {
|
||||||
|
vo.setId(id.toString());
|
||||||
|
}
|
||||||
|
|
||||||
vo.setName((String) row[1]);
|
vo.setName((String) row[1]);
|
||||||
vo.setCoverImg((String) row[2]);
|
vo.setCoverImg((String) row[2]);
|
||||||
vo.setSysType1((String) row[3]);
|
vo.setSysType1((String) row[3]);
|
||||||
@@ -146,18 +150,45 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
vo.setResOwner3((String) row[8]);
|
vo.setResOwner3((String) row[8]);
|
||||||
vo.setSysCreateBy((String) row[9]);
|
vo.setSysCreateBy((String) row[9]);
|
||||||
vo.setCreateFrom((String) row[10]);
|
vo.setCreateFrom((String) row[10]);
|
||||||
// 增加对Timestamp和LocalDateTime的兼容性
|
|
||||||
|
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
||||||
Timestamp sysCreateTimestamp = (Timestamp) row[11];
|
Timestamp sysCreateTimestamp = (Timestamp) row[11];
|
||||||
vo.setSysCreateTime(sysCreateTimestamp.toLocalDateTime());
|
if (sysCreateTimestamp != null) {
|
||||||
|
vo.setSysCreateTime(sysCreateTimestamp.toLocalDateTime());
|
||||||
|
}
|
||||||
|
|
||||||
vo.setForUsers((String) row[12]);
|
vo.setForUsers((String) row[12]);
|
||||||
vo.setStatus((Integer) row[13]);
|
vo.setStatus((Integer) row[13]);
|
||||||
vo.setPublished((Boolean) row[14]);
|
vo.setPublished((Boolean) row[14]);
|
||||||
// 增加对Timestamp和LocalDateTime的兼容性
|
|
||||||
|
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
||||||
Timestamp publishTimestamp = (Timestamp) row[15];
|
Timestamp publishTimestamp = (Timestamp) row[15];
|
||||||
vo.setPublishTime(publishTimestamp.toLocalDateTime());
|
if (publishTimestamp != null) {
|
||||||
vo.setStudys(((Number) row[16]).intValue());
|
vo.setPublishTime(publishTimestamp.toLocalDateTime());
|
||||||
vo.setScore(((Number) row[17]).floatValue());
|
}
|
||||||
vo.setCourseDuration(((Number) row[18]).longValue());
|
|
||||||
|
// 防止Number为null的情况
|
||||||
|
Number studysNum = (Number) row[16];
|
||||||
|
if (studysNum != null) {
|
||||||
|
vo.setStudys(studysNum.intValue());
|
||||||
|
} else {
|
||||||
|
vo.setStudys(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Number scoreNum = (Number) row[17];
|
||||||
|
if (scoreNum != null) {
|
||||||
|
vo.setScore(scoreNum.floatValue());
|
||||||
|
} else {
|
||||||
|
vo.setScore(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Number durationNum = (Number) row[18];
|
||||||
|
if (durationNum != null) {
|
||||||
|
vo.setCourseDuration(durationNum.longValue());
|
||||||
|
} else {
|
||||||
|
vo.setCourseDuration(0L);
|
||||||
|
}
|
||||||
|
|
||||||
vo.setEnabled((Boolean) row[19]);
|
vo.setEnabled((Boolean) row[19]);
|
||||||
vo.setOpenCourse((Integer) row[20]);
|
vo.setOpenCourse((Integer) row[20]);
|
||||||
vo.setIsTop((Boolean) row[21]);
|
vo.setIsTop((Boolean) row[21]);
|
||||||
|
|||||||
Reference in New Issue
Block a user