Browse Source

serviceType rq 추가

pull/2/head
hhjk00 10 months ago
parent
commit
b930ca7079
  1. 12
      src/containers/statistics/AbnormalSituationContainer.js
  2. 12
      src/containers/statistics/FlightContainer.js
  3. 12
      src/containers/statistics/FlightResultContainer.js
  4. 8
      src/modules/statistics/actions/index.ts
  5. 32
      src/modules/statistics/apis/index.ts
  6. 5
      src/modules/statistics/models/index.ts
  7. 6
      src/modules/statistics/sagas/index.ts

12
src/containers/statistics/AbnormalSituationContainer.js

@ -14,6 +14,7 @@ export default function AbnormalSituationContainer() {
const [searchType, setSearchType] = useState({ const [searchType, setSearchType] = useState({
category: 'PLAN', category: 'PLAN',
dateType: 'year', dateType: 'year',
serviceType: '',
year: new Date().getFullYear(), year: new Date().getFullYear(),
month: new Date().getMonth() + 1, month: new Date().getMonth() + 1,
day: new Date().getDate() day: new Date().getDate()
@ -32,8 +33,10 @@ export default function AbnormalSituationContainer() {
}; };
useEffect(() => { useEffect(() => {
dispatch(StcsActions.ABNORMAL_STCS.request()); dispatch(
}, []); StcsActions.ABNORMAL_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
useEffect(() => { useEffect(() => {
const { year, month } = searchType; const { year, month } = searchType;
@ -44,7 +47,7 @@ export default function AbnormalSituationContainer() {
}, [searchType.month]); }, [searchType.month]);
useEffect(() => { useEffect(() => {
const { category, dateType, year, month, day } = searchType; const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = { const dateMapping = {
month: year, month: year,
@ -57,7 +60,8 @@ export default function AbnormalSituationContainer() {
StcsActions.ABNORMAL_STCS_SEARCH.request({ StcsActions.ABNORMAL_STCS_SEARCH.request({
cate: category, cate: category,
date, date,
type: dateType type: dateType,
serviceType
}) })
); );
}, [searchType]); }, [searchType]);

12
src/containers/statistics/FlightContainer.js

@ -12,6 +12,7 @@ export default function FlightContainer() {
const [searchType, setSearchType] = useState({ const [searchType, setSearchType] = useState({
category: 'TIME', category: 'TIME',
dateType: 'year', dateType: 'year',
serviceType: '',
year: new Date().getFullYear(), year: new Date().getFullYear(),
month: new Date().getMonth() + 1, month: new Date().getMonth() + 1,
day: new Date().getDate() day: new Date().getDate()
@ -30,8 +31,10 @@ export default function FlightContainer() {
}; };
useEffect(() => { useEffect(() => {
dispatch(StcsActions.FLIGHT_STCS.request()); dispatch(
}, []); StcsActions.FLIGHT_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
// 해당 월에 맞는 요일 표출 // 해당 월에 맞는 요일 표출
useEffect(() => { useEffect(() => {
@ -43,7 +46,7 @@ export default function FlightContainer() {
}, [searchType.month]); }, [searchType.month]);
useEffect(() => { useEffect(() => {
const { category, dateType, year, month, day } = searchType; const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = { const dateMapping = {
month: year, month: year,
@ -56,7 +59,8 @@ export default function FlightContainer() {
StcsActions.FLIGHT_STCS_SEARCH.request({ StcsActions.FLIGHT_STCS_SEARCH.request({
cate: category, cate: category,
date, date,
type: dateType type: dateType,
serviceType
}) })
); );
}, [searchType]); }, [searchType]);

12
src/containers/statistics/FlightResultContainer.js

@ -12,6 +12,7 @@ export default function ResultContainer() {
const [searchType, setSearchType] = useState({ const [searchType, setSearchType] = useState({
category: 'FLT_RESULT', category: 'FLT_RESULT',
dateType: 'year', dateType: 'year',
serviceType: '',
year: new Date().getFullYear(), year: new Date().getFullYear(),
month: new Date().getMonth() + 1, month: new Date().getMonth() + 1,
day: new Date().getDate() day: new Date().getDate()
@ -30,8 +31,10 @@ export default function ResultContainer() {
}; };
useEffect(() => { useEffect(() => {
dispatch(StcsActions.RESULT_STCS.request()); dispatch(
}, []); StcsActions.RESULT_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
// 해당 월에 맞는 요일 표출 // 해당 월에 맞는 요일 표출
useEffect(() => { useEffect(() => {
@ -43,7 +46,7 @@ export default function ResultContainer() {
}, [searchType.month]); }, [searchType.month]);
useEffect(() => { useEffect(() => {
const { category, dateType, year, month, day } = searchType; const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = { const dateMapping = {
month: year, month: year,
@ -56,7 +59,8 @@ export default function ResultContainer() {
StcsActions.RESULT_STCS_SEARCH.request({ StcsActions.RESULT_STCS_SEARCH.request({
cate: category, cate: category,
date, date,
type: dateType type: dateType,
serviceType
}) })
); );
}, [searchType]); }, [searchType]);

8
src/modules/statistics/actions/index.ts

@ -1,6 +1,6 @@
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import { createAsyncAction, ActionType } from 'typesafe-actions'; import { createAsyncAction, ActionType } from 'typesafe-actions';
import { IStcsRs, IStcsSearchRq, IStcsSearchRs } from '../models'; import { IStcsRq, IStcsRs, IStcsSearchRq, IStcsSearchRs } from '../models';
// 비행 통계 (비행시간, 비행거리, 비행횟수) // 비행 통계 (비행시간, 비행거리, 비행횟수)
const FLIGHT_STCS_REQUEST = 'statistics/flight/FLIGHT_STCS_REQUEST'; const FLIGHT_STCS_REQUEST = 'statistics/flight/FLIGHT_STCS_REQUEST';
@ -43,7 +43,7 @@ export const FLIGHT_STCS = createAsyncAction(
FLIGHT_STCS_REQUEST, FLIGHT_STCS_REQUEST,
FLIGHT_STCS_SUCCESS, FLIGHT_STCS_SUCCESS,
FLIGHT_STCS_FAILURE FLIGHT_STCS_FAILURE
)<null, IStcsRs[], AxiosError>(); )<IStcsRq, IStcsRs[], AxiosError>();
export const FLIGHT_STCS_SEARCH = createAsyncAction( export const FLIGHT_STCS_SEARCH = createAsyncAction(
FLIGHT_STCS_SEARCH_REQUEST, FLIGHT_STCS_SEARCH_REQUEST,
@ -55,7 +55,7 @@ export const ABNORMAL_STCS = createAsyncAction(
ABNORMAL_STCS_REQUEST, ABNORMAL_STCS_REQUEST,
ABNORMAL_STCS_SUCCESS, ABNORMAL_STCS_SUCCESS,
ABNORMAL_STCS_FAILURE ABNORMAL_STCS_FAILURE
)<null, IStcsRs[], AxiosError>(); )<IStcsRq, IStcsRs[], AxiosError>();
export const ABNORMAL_STCS_SEARCH = createAsyncAction( export const ABNORMAL_STCS_SEARCH = createAsyncAction(
ABNORMAL_STCS_SEARCH_REQUEST, ABNORMAL_STCS_SEARCH_REQUEST,
@ -67,7 +67,7 @@ export const RESULT_STCS = createAsyncAction(
RESULT_STCS_REQUEST, RESULT_STCS_REQUEST,
RESULT_STCS_SUCCESS, RESULT_STCS_SUCCESS,
RESULT_STCS_FAILURE RESULT_STCS_FAILURE
)<null, IStcsRs[], AxiosError>(); )<IStcsRq, IStcsRs[], AxiosError>();
export const RESULT_STCS_SEARCH = createAsyncAction( export const RESULT_STCS_SEARCH = createAsyncAction(
RESULT_STCS_SEARCH_REQUEST, RESULT_STCS_SEARCH_REQUEST,

32
src/modules/statistics/apis/index.ts

@ -1,10 +1,16 @@
import axios from '../../utils/customAxiosUtil'; import axios from '../../utils/customAxiosUtil';
import qs from 'qs'; import qs from 'qs';
import { IStcsSearchRq } from '../models'; import { IStcsRq, IStcsSearchRq } from '../models';
export const statisticsAPI = { export const statisticsAPI = {
flight: async () => { flight: async (data: IStcsRq) => {
return await axios.get('/api/main/statistics/flight-static'); const { serviceType } = data;
return await axios.get(
`/api/main/statistics/flight-static${
serviceType ? '?serviceType=' + serviceType : ''
}`
);
}, },
flightSearch: async (data: IStcsSearchRq) => { flightSearch: async (data: IStcsSearchRq) => {
const { type } = data; const { type } = data;
@ -21,8 +27,14 @@ export const statisticsAPI = {
return await axios.get(`api/main/statistics/flight/${type}${queryString}`); return await axios.get(`api/main/statistics/flight/${type}${queryString}`);
}, },
abnormal: async () => { abnormal: async (data: IStcsRq) => {
return await axios.get('/api/main/statistics/warn-static'); const { serviceType } = data;
return await axios.get(
`/api/main/statistics/warn-static${
serviceType ? '?serviceType=' + serviceType : ''
}`
);
}, },
abnormalSearch: async (data: IStcsSearchRq) => { abnormalSearch: async (data: IStcsSearchRq) => {
const { type } = data; const { type } = data;
@ -39,8 +51,14 @@ export const statisticsAPI = {
return await axios.get(`api/main/statistics/warn/${type}${queryString}`); return await axios.get(`api/main/statistics/warn/${type}${queryString}`);
}, },
result: async () => { result: async (data: IStcsRq) => {
return await axios.get('/api/main/statistics/flight/result-static'); const { serviceType } = data;
return await axios.get(
`/api/main/statistics/flight/result-static${
serviceType ? '?serviceType=' + serviceType : ''
}`
);
}, },
resultSearch: async (data: IStcsSearchRq) => { resultSearch: async (data: IStcsSearchRq) => {
const { type } = data; const { type } = data;

5
src/modules/statistics/models/index.ts

@ -7,6 +7,10 @@ export interface IStatisticsState {
resultSearch: IStcsSearchRs; resultSearch: IStcsSearchRs;
} }
export interface IStcsRq {
serviceType: string;
}
export interface IStcsRs { export interface IStcsRs {
name: string; name: string;
year: number | string; year: number | string;
@ -27,6 +31,7 @@ export interface IStcsSearchRq {
cate: string; cate: string;
date: string; date: string;
type: string; type: string;
serviceType: string;
} }
export const initialState = { export const initialState = {

6
src/modules/statistics/sagas/index.ts

@ -9,7 +9,7 @@ function* flightStcsSaga(
) { ) {
try { try {
const payload = action.payload; const payload = action.payload;
const res = yield call(Apis.statisticsAPI.flight); const res = yield call(Apis.statisticsAPI.flight, payload);
const { data, errorCode } = res; const { data, errorCode } = res;
if (errorCode) { if (errorCode) {
@ -63,7 +63,7 @@ function* abnormalStcsSaga(
) { ) {
try { try {
const payload = action.payload; const payload = action.payload;
const res = yield call(Apis.statisticsAPI.abnormal); const res = yield call(Apis.statisticsAPI.abnormal, payload);
const { data, errorCode } = res; const { data, errorCode } = res;
if (errorCode) { if (errorCode) {
@ -117,7 +117,7 @@ function* resultStcsSaga(
) { ) {
try { try {
const payload = action.payload; const payload = action.payload;
const res = yield call(Apis.statisticsAPI.result); const res = yield call(Apis.statisticsAPI.result, payload);
const { data, errorCode } = res; const { data, errorCode } = res;
if (errorCode) { if (errorCode) {

Loading…
Cancel
Save