add prepare data log method:POST
This commit is contained in:
parent
cc26192b65
commit
29527c512e
8 changed files with 32 additions and 14 deletions
|
|
@ -148,7 +148,9 @@ export class DevelopmentController extends Controller {
|
||||||
status: "success",
|
status: "success",
|
||||||
description: "Store Development.",
|
description: "Store Development.",
|
||||||
});
|
});
|
||||||
|
const before = null;
|
||||||
await this.developmentRepository.save(development, { data: request });
|
await this.developmentRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
return new HttpSuccess(development.id);
|
return new HttpSuccess(development.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2151,7 +2153,7 @@ export class DevelopmentController extends Controller {
|
||||||
const sheetName = workbook.SheetNames[0]; // Assuming we're reading the first sheet
|
const sheetName = workbook.SheetNames[0]; // Assuming we're reading the first sheet
|
||||||
const sheet = workbook.Sheets[sheetName];
|
const sheet = workbook.Sheets[sheetName];
|
||||||
const getDevelopments = xlsx.utils.sheet_to_json(sheet);
|
const getDevelopments = xlsx.utils.sheet_to_json(sheet);
|
||||||
|
const before = null;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
getDevelopments.map(async (item: any) => {
|
getDevelopments.map(async (item: any) => {
|
||||||
if (item["รหัสประจำตัวประชาชน"] == undefined || item["รหัสประจำตัวประชาชน"].length != 13)
|
if (item["รหัสประจำตัวประชาชน"] == undefined || item["รหัสประจำตัวประชาชน"].length != 13)
|
||||||
|
|
@ -2184,6 +2186,7 @@ export class DevelopmentController extends Controller {
|
||||||
description: "Store DevelopmentHistory.",
|
description: "Store DevelopmentHistory.",
|
||||||
});
|
});
|
||||||
await this.developmentHistoryRepository.save(oldProfile, { data: request });
|
await this.developmentHistoryRepository.save(oldProfile, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: oldProfile });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item["ประเภท"] == undefined) return;
|
if (item["ประเภท"] == undefined) return;
|
||||||
|
|
@ -2221,6 +2224,7 @@ export class DevelopmentController extends Controller {
|
||||||
description: "Store DevelopmentHistory.",
|
description: "Store DevelopmentHistory.",
|
||||||
});
|
});
|
||||||
await this.developmentHistoryRepository.save(development, { data: request });
|
await this.developmentHistoryRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
})
|
})
|
||||||
.catch((x) => {
|
.catch((x) => {
|
||||||
return;
|
return;
|
||||||
|
|
@ -2259,6 +2263,7 @@ export class DevelopmentController extends Controller {
|
||||||
description: "Store DevelopmentHistory.",
|
description: "Store DevelopmentHistory.",
|
||||||
});
|
});
|
||||||
await this.developmentHistoryRepository.save(development, { data: request });
|
await this.developmentHistoryRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
})
|
})
|
||||||
.catch((x) => {
|
.catch((x) => {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import {
|
||||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { addLogSequence } from "../interfaces/utils";
|
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||||
|
|
||||||
@Route("api/v1/development/history/employee")
|
@Route("api/v1/development/history/employee")
|
||||||
@Tags("DevelopmentEmployeeHistory")
|
@Tags("DevelopmentEmployeeHistory")
|
||||||
|
|
@ -110,7 +110,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
const development = Object.assign(new DevelopmentHistory(), requestBody);
|
const development = Object.assign(new DevelopmentHistory(), requestBody);
|
||||||
development.type = type;
|
development.type = type;
|
||||||
development.employeePosTypeId = requestBody.posTypeId;
|
development.employeePosTypeId = requestBody.posTypeId;
|
||||||
|
|
@ -127,6 +127,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
|
||||||
description: "Store DevelopmentHistory.",
|
description: "Store DevelopmentHistory.",
|
||||||
});
|
});
|
||||||
await this.developmentHistoryRepository.save(development, { data: request });
|
await this.developmentHistoryRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
return new HttpSuccess(development.id);
|
return new HttpSuccess(development.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import {
|
||||||
import { PosType } from "../entities/PosType";
|
import { PosType } from "../entities/PosType";
|
||||||
import { PosLevel } from "../entities/PosLevel";
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { addLogSequence } from "../interfaces/utils";
|
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||||
|
|
||||||
@Route("api/v1/development/history/officer")
|
@Route("api/v1/development/history/officer")
|
||||||
@Tags("DevelopmentOfficerHistory")
|
@Tags("DevelopmentOfficerHistory")
|
||||||
|
|
@ -110,7 +110,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
const development = Object.assign(new DevelopmentHistory(), requestBody);
|
const development = Object.assign(new DevelopmentHistory(), requestBody);
|
||||||
development.type = type;
|
development.type = type;
|
||||||
development.createdUserId = request.user.sub;
|
development.createdUserId = request.user.sub;
|
||||||
|
|
@ -123,6 +123,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
description: "Store DevelopmentHistory.",
|
description: "Store DevelopmentHistory.",
|
||||||
});
|
});
|
||||||
await this.developmentHistoryRepository.save(development, { data: request });
|
await this.developmentHistoryRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
return new HttpSuccess(development.id);
|
return new HttpSuccess(development.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export class DevelopmentScholarshipController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
const development = Object.assign(new DevelopmentScholarship(), requestBody);
|
const development = Object.assign(new DevelopmentScholarship(), requestBody);
|
||||||
development.createdUserId = request.user.sub;
|
development.createdUserId = request.user.sub;
|
||||||
development.createdFullName = request.user.name;
|
development.createdFullName = request.user.name;
|
||||||
|
|
@ -87,6 +87,7 @@ export class DevelopmentScholarshipController extends Controller {
|
||||||
description: "Store Development Scholarship.",
|
description: "Store Development Scholarship.",
|
||||||
});
|
});
|
||||||
await this.developmentScholarshipRepository.save(development, { data: request });
|
await this.developmentScholarshipRepository.save(development, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: development });
|
||||||
return new HttpSuccess(development.id);
|
return new HttpSuccess(development.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import HttpError from "../interfaces/http-error";
|
||||||
import { Not } from "typeorm";
|
import { Not } from "typeorm";
|
||||||
import { CreatePortfolio, Portfolio } from "../entities/Portfolio";
|
import { CreatePortfolio, Portfolio } from "../entities/Portfolio";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { addLogSequence } from "../interfaces/utils";
|
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||||
|
|
||||||
@Route("api/v1/development/portfolio")
|
@Route("api/v1/development/portfolio")
|
||||||
@Tags("Portfolio")
|
@Tags("Portfolio")
|
||||||
|
|
@ -101,7 +101,7 @@ export class PortfolioController extends Controller {
|
||||||
if (checkName) {
|
if (checkName) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
_portfolio.createdUserId = request.user.sub;
|
_portfolio.createdUserId = request.user.sub;
|
||||||
_portfolio.createdFullName = request.user.name;
|
_portfolio.createdFullName = request.user.name;
|
||||||
_portfolio.lastUpdateUserId = request.user.sub;
|
_portfolio.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -112,6 +112,7 @@ export class PortfolioController extends Controller {
|
||||||
description: "Store Portfolio.",
|
description: "Store Portfolio.",
|
||||||
});
|
});
|
||||||
await this.portfolioRepository.save(_portfolio, { data: request });
|
await this.portfolioRepository.save(_portfolio, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: _portfolio });
|
||||||
return new HttpSuccess(_portfolio.id);
|
return new HttpSuccess(_portfolio.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import { Check } from "typeorm";
|
import { Check } from "typeorm";
|
||||||
import { addLogSequence } from "../interfaces/utils";
|
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
|
|
||||||
@Route("api/v1/development/strategy")
|
@Route("api/v1/development/strategy")
|
||||||
|
|
@ -199,7 +199,7 @@ export class StrategyController extends Controller {
|
||||||
default:
|
default:
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
const before = null;
|
||||||
strategyChild.createdUserId = request.user.sub;
|
strategyChild.createdUserId = request.user.sub;
|
||||||
strategyChild.createdFullName = request.user.name;
|
strategyChild.createdFullName = request.user.name;
|
||||||
strategyChild.lastUpdateUserId = request.user.sub;
|
strategyChild.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -210,6 +210,7 @@ export class StrategyController extends Controller {
|
||||||
description: "Store Strategy.",
|
description: "Store Strategy.",
|
||||||
});
|
});
|
||||||
await repoSave.save(strategyChild, { data: request });
|
await repoSave.save(strategyChild, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: strategyChild });
|
||||||
|
|
||||||
return new HttpSuccess(strategyChild.id);
|
return new HttpSuccess(strategyChild.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,11 @@ class CallAPI {
|
||||||
addLogSequence(request, {
|
addLogSequence(request, {
|
||||||
action: "request",
|
action: "request",
|
||||||
status: "success",
|
status: "success",
|
||||||
description: JSON.stringify(response.data.result),
|
description: "connected",
|
||||||
request: {
|
request: {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
|
response: JSON.stringify(response.data.result),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
@ -40,10 +41,11 @@ class CallAPI {
|
||||||
addLogSequence(request, {
|
addLogSequence(request, {
|
||||||
action: "request",
|
action: "request",
|
||||||
status: "error",
|
status: "error",
|
||||||
description: JSON.stringify(error),
|
description: "unconnected",
|
||||||
request: {
|
request: {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
|
response: JSON.stringify(error),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -63,10 +65,12 @@ class CallAPI {
|
||||||
addLogSequence(request, {
|
addLogSequence(request, {
|
||||||
action: "request",
|
action: "request",
|
||||||
status: "success",
|
status: "success",
|
||||||
description: JSON.stringify(response.data.result),
|
description: "connected",
|
||||||
request: {
|
request: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
|
payload: JSON.stringify(sendData),
|
||||||
|
response: JSON.stringify(response.data.result),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
@ -74,10 +78,12 @@ class CallAPI {
|
||||||
addLogSequence(request, {
|
addLogSequence(request, {
|
||||||
action: "request",
|
action: "request",
|
||||||
status: "error",
|
status: "error",
|
||||||
description: JSON.stringify(error),
|
description: "unconnected",
|
||||||
request: {
|
request: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
|
payload: JSON.stringify(sendData),
|
||||||
|
response: JSON.stringify(error),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ export type LogSequence = {
|
||||||
request?: {
|
request?: {
|
||||||
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
||||||
url: string;
|
url: string;
|
||||||
|
payload?: string;
|
||||||
|
response?: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue