优化代码

This commit is contained in:
Administrator 2024-05-13 09:39:11 +08:00
parent 199c44cff4
commit 8eee1fa0de
2 changed files with 7 additions and 6 deletions

View File

@ -88,10 +88,6 @@
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
<repository>
<id>epay-sdk</id>
<url>https://gitee.com/gitwcx/epay-sdk-java/raw/master/release/</url>
</repository>
</repositories>
</project>

View File

@ -92,10 +92,15 @@ public class ApiHomeServiceImpl implements ApiHomeService {
WebConfig webConfig = webConfigMapper.selectOne(null);
//获取访问量
Object count = redisService.getCacheObject(RedisConstants.BLOG_VIEWS_COUNT);
Long count = Optional.ofNullable(redisService.getCacheObject(RedisConstants.BLOG_VIEWS_COUNT))
.map(Object::toString)
.map(Long::valueOf)
.orElse(0L);
//获取访客量
Long visitorAccess = redisService.getCacheSetKeyNumber(RedisConstants.UNIQUE_VISITOR);
return ResponseResult.success(webConfig).putExtra("siteAccess", Optional.ofNullable(count).orElse(0))
return ResponseResult.success(webConfig).putExtra("siteAccess", count)
.putExtra("visitorAccess",visitorAccess);
}