Files
wechatWeb/api/controller_admin/biz_api_stats.js
张成 494555a6e1 1
2026-04-01 10:13:22 +08:00

46 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const stats = require("../service/biz_api_stats_service");
const crud = require("../service/biz_admin_crud");
module.exports = {
/** 按用户查询调用统计 */
"POST /biz_api_stats/by_user": async (ctx) => {
const body = ctx.getBody();
const { user_id, start_date, end_date } = body;
if (!user_id) {
ctx.fail("缺少 user_id");
return;
}
const data = await stats.getStatsByUser(user_id, start_date, end_date);
ctx.success(data);
},
/** 按接口路径查询调用统计 */
"POST /biz_api_stats/by_api": async (ctx) => {
const body = ctx.getBody();
const { api_path, start_date, end_date } = body;
if (!api_path) {
ctx.fail("缺少 api_path");
return;
}
const data = await stats.getStatsByApi(api_path, start_date, end_date);
ctx.success(data);
},
/** 综合统计面板 */
"POST /biz_api_stats/summary": async (ctx) => {
const body = ctx.getBody();
const { start_date, end_date, top_limit } = body;
const data = await stats.getSummary(start_date, end_date, top_limit || 10);
ctx.success(data);
},
/** 调用日志分页列表(复用通用 CRUD */
"POST /biz_api_call_log/page": async (ctx) => {
const body = ctx.getBody();
const data = await crud.page("biz_api_call_log", body);
ctx.success({ rows: data.rows, count: data.count });
},
};