add: сервис для отчетов фронта
This commit is contained in:
parent
0bdf0c9f6c
commit
15a39c07a0
@ -165,6 +165,45 @@ export class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType
|
|||||||
format: "json",
|
format: "json",
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags Report
|
||||||
|
* @name ReportPeriodList
|
||||||
|
* @request GET:/api/Report/period
|
||||||
|
* @response `200` `(ChangeRecordViewModel)[]` Success
|
||||||
|
*/
|
||||||
|
reportPeriodList = (
|
||||||
|
query?: {
|
||||||
|
/** @format date-time */
|
||||||
|
from?: string;
|
||||||
|
/** @format date-time */
|
||||||
|
to?: string;
|
||||||
|
},
|
||||||
|
params: RequestParams = {},
|
||||||
|
) =>
|
||||||
|
this.request<ChangeRecordViewModel[], any>({
|
||||||
|
path: `/api/Report/period`,
|
||||||
|
method: "GET",
|
||||||
|
query: query,
|
||||||
|
format: "json",
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags Report
|
||||||
|
* @name ReportPlanDetail
|
||||||
|
* @request GET:/api/Report/plan/{id}
|
||||||
|
* @response `200` `SpendingGroupViewModel` Success
|
||||||
|
*/
|
||||||
|
reportPlanDetail = (id: string, params: RequestParams = {}) =>
|
||||||
|
this.request<SpendingGroupViewModel, any>({
|
||||||
|
path: `/api/Report/plan/${id}`,
|
||||||
|
method: "GET",
|
||||||
|
format: "json",
|
||||||
|
...params,
|
||||||
|
});
|
||||||
/**
|
/**
|
||||||
* No description
|
* No description
|
||||||
*
|
*
|
||||||
@ -412,7 +451,7 @@ export class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType
|
|||||||
* @request GET:/api/User
|
* @request GET:/api/User
|
||||||
* @response `200` `UserViewModel` Success
|
* @response `200` `UserViewModel` Success
|
||||||
*/
|
*/
|
||||||
userGet = (
|
userList = (
|
||||||
query?: {
|
query?: {
|
||||||
/** @format uuid */
|
/** @format uuid */
|
||||||
Id?: string;
|
Id?: string;
|
||||||
|
@ -28,8 +28,7 @@ export interface ChangeRecordViewModel {
|
|||||||
id?: string;
|
id?: string;
|
||||||
/** @format double */
|
/** @format double */
|
||||||
sum?: number;
|
sum?: number;
|
||||||
/** @format date-time */
|
changedAt?: string | null;
|
||||||
changedAt?: string;
|
|
||||||
spendingGroupName?: string | null;
|
spendingGroupName?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,10 +66,8 @@ export interface SpendingPlanDto {
|
|||||||
export interface SpendingPlanViewModel {
|
export interface SpendingPlanViewModel {
|
||||||
/** @format uuid */
|
/** @format uuid */
|
||||||
id?: string;
|
id?: string;
|
||||||
/** @format date-time */
|
startAt?: string | null;
|
||||||
startAt?: string;
|
endAt?: string | null;
|
||||||
/** @format date-time */
|
|
||||||
endAt?: string;
|
|
||||||
/** @format double */
|
/** @format double */
|
||||||
sum?: number;
|
sum?: number;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ export enum ContentType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class HttpClient<SecurityDataType = unknown> {
|
export class HttpClient<SecurityDataType = unknown> {
|
||||||
public baseUrl: string = import.meta.env.VITE_API_URL;
|
public baseUrl: string = "http://172.29.224.204:5215";
|
||||||
private securityData: SecurityDataType | null = null;
|
private securityData: SecurityDataType | null = null;
|
||||||
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
|
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
|
||||||
private abortControllers = new Map<CancelToken, AbortController>();
|
private abortControllers = new Map<CancelToken, AbortController>();
|
||||||
|
25
front/src/core/services/report-service.ts
Normal file
25
front/src/core/services/report-service.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Dayjs } from "dayjs";
|
||||||
|
import { Api } from "../api/Api";
|
||||||
|
import { SpendingGroupViewModel } from "../api/data-contracts";
|
||||||
|
|
||||||
|
export class ReportService {
|
||||||
|
private readonly _api: Api
|
||||||
|
constructor(api: Api) {
|
||||||
|
this._api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOffsetFromPlanData(Id: string): Promise<SpendingGroupViewModel> {
|
||||||
|
let res = await this._api.reportPlanDetail(Id);
|
||||||
|
console.log(res);
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getPeriodData(from: Dayjs, to: Dayjs): Promise<SpendingGroupViewModel[]> {
|
||||||
|
let res = await this._api.reportPeriodList({
|
||||||
|
from: from.toISOString(),
|
||||||
|
to: to.toISOString()
|
||||||
|
});
|
||||||
|
console.log(res);
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import { AuthService } from './core/services/auth-service'
|
|||||||
import { ChangeRecordService } from './core/services/change-record-service'
|
import { ChangeRecordService } from './core/services/change-record-service'
|
||||||
import { GroupService } from './core/services/group-service'
|
import { GroupService } from './core/services/group-service'
|
||||||
import { PlanService } from './core/services/plans-service'
|
import { PlanService } from './core/services/plans-service'
|
||||||
|
import { ReportService } from './core/services/report-service'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
@ -20,5 +21,6 @@ app.provide(AuthService.name, new AuthService(api));
|
|||||||
app.provide(ChangeRecordService.name, new ChangeRecordService(api));
|
app.provide(ChangeRecordService.name, new ChangeRecordService(api));
|
||||||
app.provide(GroupService.name, new GroupService(api));
|
app.provide(GroupService.name, new GroupService(api));
|
||||||
app.provide(PlanService.name, new PlanService(api));
|
app.provide(PlanService.name, new PlanService(api));
|
||||||
|
app.provide(ReportService.name, new ReportService(api));
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
Loading…
Reference in New Issue
Block a user