ApproveController.ts 1.41 KB
import { AxiosResponse, AxiosStatic } from "axios";
import dayjs, { Dayjs } from "dayjs";
import { DateCount } from "lib/src/entity/analysis/domain/DateCount";
// region 前端扩展导入包
import { ApproveHistory } from "lib/src/entity/track/entity/ApproveHistory";
import { ApproveView } from "lib/src/entity/track/entity/ApproveView";
// endregion

/**
 */
export const ApproveController = {
	/**
	 */
	getApproveHistoriesByApproveId(
		axios: AxiosStatic,
		approveType: any,
		approveId: number,
	): Promise<AxiosResponse<ApproveHistory[]>> {
		return axios.get("approve/getApproveHistoriesByApproveId", {
			params: { approveType, approveId },
		});
	},

	/**
	 */
	getApproveViewCount(axios: AxiosStatic): Promise<AxiosResponse<number>> {
		return axios.get("approve/getApproveViewCount");
	},

	/**
	 */
	getApproveViewsCountByDate(axios: AxiosStatic, date: Dayjs | string): Promise<AxiosResponse<DateCount[]>> {
		if (date instanceof Object) {
			date = dayjs(date).format("YYYY-MM-DD");
		}

		return axios.get("approve/getApproveViewsCountByDate", { params: { date } });
	},

	/**
	 */
	getLastApproveViews(
		axios: AxiosStatic,
		date: Dayjs | null | string | undefined,
	): Promise<AxiosResponse<ApproveView[]>> {
		if (date instanceof Object) {
			date = dayjs(date).format("YYYY-MM-DD");
		}

		return axios.get("approve/getLastApproveViews", { params: { date } });
	},

	// region 前端扩展代码区
	// endregion
};