Dashboard - 다운로드수
parent
f14ee3b03d
commit
8e22399ec4
|
|
@ -198,6 +198,13 @@ function EgovAdminDashboard(props) {
|
|||
|
||||
// const [value, setValue] = useState('today');
|
||||
const [slot, setSlot] = useState('week');
|
||||
const [totalDownloads, setTotalDownloads] = useState(0);
|
||||
|
||||
// 총 다운로드 수를 받아온 후 state 업데이트
|
||||
const handleTotalDownloads = (sum) => {
|
||||
setTotalDownloads(sum);
|
||||
console.log(sum);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
|
|
@ -290,10 +297,10 @@ function EgovAdminDashboard(props) {
|
|||
<Typography variant="h3" color="textSecondary">
|
||||
주간 현황
|
||||
</Typography>
|
||||
<Typography variant="h6">총 2,300건</Typography>
|
||||
<Typography variant="h6">총 {totalDownloads}건</Typography>
|
||||
</Stack>
|
||||
</Box>
|
||||
<MonthlyBarChart />
|
||||
<MonthlyBarChart onDataFetched={handleTotalDownloads} />
|
||||
</MainCard>
|
||||
</Grid>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import {useCallback, useEffect, useState} from 'react';
|
||||
|
||||
// material-ui
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
|
|
@ -6,6 +6,8 @@ import { useTheme } from '@mui/material/styles';
|
|||
// third-party
|
||||
import ReactApexChart from 'react-apexcharts';
|
||||
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
|
||||
// chart options
|
||||
const barChartOptions = {
|
||||
chart: {
|
||||
|
|
@ -22,7 +24,7 @@ const barChartOptions = {
|
|||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
enabled: true
|
||||
},
|
||||
xaxis: {
|
||||
categories: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
|
||||
|
|
@ -43,37 +45,75 @@ const barChartOptions = {
|
|||
|
||||
// ==============================|| MONTHLY BAR CHART ||============================== //
|
||||
|
||||
const MonthlyBarChart = () => {
|
||||
const MonthlyBarChart = ({ onDataFetched }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const { primary, secondary } = theme.palette.text;
|
||||
const info = theme.palette.info.light;
|
||||
|
||||
const [series] = useState([
|
||||
const [options, setOptions] = useState(barChartOptions);
|
||||
const [fileDailyList, setFileDailyList] = useState([]);
|
||||
|
||||
// 메뉴 접속 및 방문자 수
|
||||
const retrieveList = useCallback(() => {
|
||||
const retrieveListURL = '/admin/dashboard/file'
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
// body: JSON.stringify()
|
||||
}
|
||||
|
||||
EgovNet.requestFetch(retrieveListURL,
|
||||
requestOptions,
|
||||
(resp) => {
|
||||
setFileDailyList(resp.result.fileDailyList);
|
||||
const sum = resp.result.fileDailyList.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
||||
onDataFetched(sum);
|
||||
},
|
||||
function (resp) {
|
||||
console.log("err response : ", resp);
|
||||
}
|
||||
);
|
||||
// eslint-disable-next-lie react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const [series, setSeries] = useState([
|
||||
{
|
||||
data: [80, 95, 70, 42, 65, 55, 78]
|
||||
data: fileDailyList
|
||||
}
|
||||
]);
|
||||
|
||||
const [options, setOptions] = useState(barChartOptions);
|
||||
useEffect(() => {
|
||||
retrieveList();
|
||||
}, [onDataFetched]);
|
||||
|
||||
useEffect(() => {
|
||||
setSeries([
|
||||
{
|
||||
data: fileDailyList
|
||||
},
|
||||
]);
|
||||
|
||||
setOptions((prevState) => ({
|
||||
...prevState,
|
||||
colors: [info],
|
||||
// labels: ['PC', 'Mobile', 'Mobile', 'Mobile', 'Mobile', 'Mobile', 'Mobile'],
|
||||
xaxis: {
|
||||
labels: {
|
||||
style: {
|
||||
colors: [secondary, secondary, secondary, secondary, secondary, secondary, secondary]
|
||||
colors: [primary, secondary, secondary, secondary, secondary, secondary, secondary]
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
theme: 'light'
|
||||
}
|
||||
},
|
||||
}));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [primary, info, secondary]);
|
||||
}, [primary, info, secondary, fileDailyList]);
|
||||
|
||||
return (
|
||||
<div id="chart">
|
||||
|
|
|
|||
|
|
@ -61,6 +61,29 @@ public class AdminDashboardController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "이번주 다운로드 조회",
|
||||
description = "이번주 다운로드 조회",
|
||||
tags = {"AdminDashboardController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/file", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO getfile(@AuthenticationPrincipal LoginVO user)
|
||||
throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
resultMap.put("fileDailyList", adminDashboardService.selectFileDaily());
|
||||
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
resultVO.setResult(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public interface MenuMonthlyRepository extends JpaRepository<TnDailyMenuLog, Lon
|
|||
" INTERVAL '1 day'" +
|
||||
" ) AS day" +
|
||||
")" +
|
||||
"SELECT COALESCE(COUNT(tn.create_dt), 0) AS log_cnt " +
|
||||
"SELECT COALESCE(SUM(tn.log_cnt), 0) AS log_cnt " +
|
||||
"FROM all_days ad " +
|
||||
"LEFT JOIN th_menu_log tn ON ad.day = DATE_TRUNC('day', tn.create_dt) " +
|
||||
"LEFT JOIN tn_daily_menu_log tn ON ad.day = DATE_TRUNC('day', tn.log_dt) " +
|
||||
"GROUP BY TO_CHAR(ad.day, 'Day') " +
|
||||
"ORDER BY MIN(ad.day)", nativeQuery = true)
|
||||
List<Long> MenuDailyList();
|
||||
|
|
@ -62,5 +62,22 @@ public interface MenuMonthlyRepository extends JpaRepository<TnDailyMenuLog, Lon
|
|||
"GROUP BY TO_CHAR(ad.day, 'Day') " +
|
||||
"ORDER BY MIN(ad.day)", nativeQuery = true)
|
||||
List<Long> LoginDailyList();
|
||||
|
||||
|
||||
|
||||
@Query(value = "WITH all_days AS (" +
|
||||
" SELECT generate_series(" +
|
||||
" DATE_TRUNC('year', CURRENT_DATE)," +
|
||||
" DATE_TRUNC('year', CURRENT_DATE) + INTERVAL '1 year' - INTERVAL '1 day'," +
|
||||
" INTERVAL '1 day'" +
|
||||
" ) AS day" +
|
||||
")" +
|
||||
"SELECT COALESCE(COUNT(tn.access_dt), 0) AS log_cnt " +
|
||||
"FROM all_days ad " +
|
||||
"LEFT JOIN (SELECT access_dt FROM public.th_attach_file_log WHERE\n" +
|
||||
" access_dt >= CURRENT_DATE - INTERVAL '6 day') tn ON ad.day = DATE_TRUNC('day', tn.access_dt) " +
|
||||
"GROUP BY TO_CHAR(ad.day, 'Day') " +
|
||||
"ORDER BY MIN(ad.day)", nativeQuery = true)
|
||||
List<Long> FileDailyList();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class AdminDashboardService extends EgovAbstractServiceImpl {
|
|||
|
||||
public List<Long> selectLoginDaily() { return menuMonthlyRepository.LoginDailyList(); }
|
||||
|
||||
|
||||
public List<Long> selectFileDaily() { return menuMonthlyRepository.FileDailyList(); }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue