-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
320 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/DashboardTotalVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package top.charles7c.cnadmin.monitor.model.vo; | ||
|
||
import java.io.Serializable; | ||
import java.math.BigDecimal; | ||
|
||
import lombok.Data; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
/** | ||
* 仪表盘总计信息 | ||
* | ||
* @author Charles7c | ||
* @since 2023/9/8 21:32 | ||
*/ | ||
@Data | ||
public class DashboardTotalVO implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* 浏览量(PV) | ||
*/ | ||
@Schema(description = "浏览量(PV)", example = "88888") | ||
private Long pvCount; | ||
|
||
/** | ||
* IP 数 | ||
*/ | ||
@Schema(description = "IP 数", example = "66666") | ||
private Long ipCount; | ||
|
||
/** | ||
* 今日浏览量(PV) | ||
*/ | ||
@Schema(description = "今日浏览量", example = "1234") | ||
private Long todayPvCount; | ||
|
||
/** | ||
* 较昨日新增 PV(百分比) | ||
*/ | ||
@Schema(description = "较昨日新增(百分比)", example = "23.4") | ||
private BigDecimal newPvFromYesterday; | ||
|
||
/** | ||
* 昨日浏览量(PV) | ||
*/ | ||
@JsonIgnore | ||
private Long yesterdayPvCount; | ||
} |
45 changes: 45 additions & 0 deletions
45
...w-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/service/DashboardService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package top.charles7c.cnadmin.monitor.service; | ||
|
||
import java.util.List; | ||
|
||
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO; | ||
import top.charles7c.cnadmin.system.model.vo.DashboardAnnouncementVO; | ||
|
||
/** | ||
* 仪表盘业务接口 | ||
* | ||
* @author Charles7c | ||
* @since 2023/9/8 21:32 | ||
*/ | ||
public interface DashboardService { | ||
|
||
/** | ||
* 查询总计信息 | ||
* | ||
* @return 总计信息 | ||
*/ | ||
DashboardTotalVO getTotal(); | ||
|
||
/** | ||
* 查询公告列表 | ||
* | ||
* @return 公告列表 | ||
*/ | ||
List<DashboardAnnouncementVO> listAnnouncement(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...onitor/src/main/java/top/charles7c/cnadmin/monitor/service/impl/DashboardServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package top.charles7c.cnadmin.monitor.service.impl; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import cn.hutool.core.util.NumberUtil; | ||
|
||
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO; | ||
import top.charles7c.cnadmin.monitor.service.DashboardService; | ||
import top.charles7c.cnadmin.monitor.service.LogService; | ||
import top.charles7c.cnadmin.system.model.vo.DashboardAnnouncementVO; | ||
import top.charles7c.cnadmin.system.service.AnnouncementService; | ||
|
||
/** | ||
* 仪表盘业务实现 | ||
* | ||
* @author Charles7c | ||
* @since 2023/9/8 21:32 | ||
*/ | ||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class DashboardServiceImpl implements DashboardService { | ||
|
||
private final LogService logService; | ||
private final AnnouncementService announcementService; | ||
|
||
@Override | ||
public DashboardTotalVO getTotal() { | ||
DashboardTotalVO totalVO = logService.getDashboardTotal(); | ||
Long todayPvCount = totalVO.getTodayPvCount(); | ||
Long yesterdayPvCount = totalVO.getYesterdayPvCount(); | ||
BigDecimal newPvCountFromYesterday = NumberUtil.sub(todayPvCount, yesterdayPvCount); | ||
BigDecimal newPvFromYesterday = (0 == yesterdayPvCount) ? BigDecimal.valueOf(100) | ||
: NumberUtil.round(NumberUtil.mul(NumberUtil.div(newPvCountFromYesterday, yesterdayPvCount), 100), 1); | ||
totalVO.setNewPvFromYesterday(newPvFromYesterday); | ||
return totalVO; | ||
} | ||
|
||
@Override | ||
public List<DashboardAnnouncementVO> listAnnouncement() { | ||
return announcementService.listDashboard(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
continew-admin-monitor/src/main/resources/mapper/LogMapper.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
<mapper namespace="top.charles7c.cnadmin.monitor.mapper.LogMapper"> | ||
<select id="selectDashboardTotal" resultType="top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO"> | ||
SELECT | ||
(SELECT COUNT(*) FROM `sys_log`) AS pvCount, | ||
(SELECT COUNT(DISTINCT `client_ip`) FROM `sys_log`) AS ipCount, | ||
(SELECT COUNT(*) FROM `sys_log` WHERE DATE(`create_time`) = CURDATE()) AS todayPvCount, | ||
(SELECT COUNT(*) FROM `sys_log` WHERE DATE(`create_time`) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)) AS yesterdayPvCount | ||
</select> | ||
</mapper> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.