47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import {RouteHandleFunction} from "../core/types";
|
|
import {listAppByUID, listAppEvent, listAppEventData} from "../service/app";
|
|
import {reportEvent} from "../service/report-service";
|
|
|
|
|
|
export const reportToServer: RouteHandleFunction =
|
|
({
|
|
body, res
|
|
}) => {
|
|
reportEvent(body).then(() => {
|
|
res.send('got and saved!')
|
|
}).catch((e: Error) => {
|
|
console.log(e)
|
|
res.send('got but not saved!')
|
|
});
|
|
}
|
|
|
|
export const appList: RouteHandleFunction =
|
|
async ({
|
|
param, res
|
|
}) => {
|
|
const apps = await listAppByUID(1);
|
|
res.send({code: 0, data: apps})
|
|
}
|
|
|
|
export const appEvent: RouteHandleFunction =
|
|
async ({
|
|
query, res, param, body
|
|
}) => {
|
|
const events = await listAppEvent(query.appId)
|
|
res.send({
|
|
code: 0,
|
|
data: events
|
|
})
|
|
}
|
|
|
|
export const eventData: RouteHandleFunction =
|
|
async ({
|
|
query, res
|
|
}) => {
|
|
const data = await listAppEventData(Number(query.appId), Number(query.page), Number(query.pageSize))
|
|
res.send({
|
|
code: 0,
|
|
data
|
|
})
|
|
}
|