fix current revision log
This commit is contained in:
parent
9265f6ec80
commit
63ed0534d0
1 changed files with 7 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import { NextFunction, Request, Response } from "express";
|
|||
import { Client } from "@elastic/elasticsearch";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
|
||||
if (!process.env.ELASTICSEARCH_INDEX) {
|
||||
throw new Error("Require ELASTICSEARCH_INDEX to store log.");
|
||||
|
|
@ -26,6 +27,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
|
||||
let data: any;
|
||||
const repoPosmaster = AppDataSource.getRepository(PosMaster);
|
||||
const repoRevision = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
const originalJson = res.json;
|
||||
|
||||
|
|
@ -38,8 +40,12 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
|
||||
req.app.locals.logData = {};
|
||||
|
||||
const revision = await repoRevision.findOne({
|
||||
where: { orgRevisionIsCurrent: true , orgRevisionIsDraft: false },
|
||||
})
|
||||
|
||||
const rootId = await repoPosmaster.findOne({
|
||||
where: { current_holderId: req.app.locals.logData.userId },
|
||||
where: { current_holderId: req.app.locals.logData.userId, orgRevisionId: revision?.id },
|
||||
});
|
||||
|
||||
res.on("finish", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue