1
This commit is contained in:
@@ -131,9 +131,9 @@ public class CommentServiceImpl implements ICommentService {
|
||||
}
|
||||
|
||||
if (statMap != null) {
|
||||
stats.setTotalCount(((Number) statMap.get("totalCount")).longValue());
|
||||
stats.setAvailableCount(((Number) statMap.get("availableCount")).longValue());
|
||||
stats.setUsedCount(((Number) statMap.get("usedCount")).longValue());
|
||||
stats.setTotalCount(toLong(statMap.get("totalCount")));
|
||||
stats.setAvailableCount(toLong(statMap.get("availableCount")));
|
||||
stats.setUsedCount(toLong(statMap.get("usedCount")));
|
||||
// 设置最后一条评论的创建时间
|
||||
Object lastUpdateTime = statMap.get("lastCommentUpdateTime");
|
||||
if (lastUpdateTime != null) {
|
||||
@@ -439,5 +439,22 @@ public class CommentServiceImpl implements ICommentService {
|
||||
|
||||
return statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 中的统计值安全转为 long,null 或不存在时返回 0
|
||||
*/
|
||||
private static long toLong(Object value) {
|
||||
if (value == null) {
|
||||
return 0L;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(value.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user