fix log
This commit is contained in:
parent
b9bc5b1298
commit
cb1eb5a68e
8 changed files with 92 additions and 56 deletions
|
|
@ -24,6 +24,7 @@ import { Brackets } from "typeorm";
|
|||
import { DevelopmentProject } from "../entities/DevelopmentProject";
|
||||
import { ProfileDevelopment } from "../entities/ProfileDevelopment";
|
||||
import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/development-request")
|
||||
@Tags("DevelopmentRequest")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -209,7 +210,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const before = null;
|
||||
const data = new DevelopmentRequest();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -224,7 +225,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
Object.assign(data, { ...body, ...meta });
|
||||
data.profileId = profile.id;
|
||||
data.status = "PENDING";
|
||||
await this.developmentRequestRepository.save(data);
|
||||
await this.developmentRequestRepository.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
|
||||
if (body.developmentProjects != null) {
|
||||
await Promise.all(
|
||||
|
|
@ -238,7 +240,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
developmentProject.createdAt = new Date();
|
||||
developmentProject.lastUpdatedAt = new Date();
|
||||
developmentProject.developmentRequestId = data.id;
|
||||
await this.developmentProjectRepository.save(developmentProject);
|
||||
await this.developmentProjectRepository.save(developmentProject, { data: req });
|
||||
setLogDataDiff(req, { before, after: developmentProject });
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
@ -255,13 +258,15 @@ export class DevelopmentRequestController extends Controller {
|
|||
where: { id: developmentId },
|
||||
relations: ["developmentProjects"],
|
||||
});
|
||||
const before = structuredClone(record);
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await this.developmentRequestRepository.save(record);
|
||||
await this.developmentRequestRepository.save(record, {data: req});
|
||||
setLogDataDiff(req, { before, after: record });
|
||||
await this.developmentProjectRepository.delete({ developmentRequestId: record.id });
|
||||
if (body.developmentProjects != null) {
|
||||
await Promise.all(
|
||||
|
|
@ -275,7 +280,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
developmentProject.createdAt = new Date();
|
||||
developmentProject.lastUpdatedAt = new Date();
|
||||
developmentProject.developmentRequestId = record.id;
|
||||
await this.developmentProjectRepository.save(developmentProject);
|
||||
await this.developmentProjectRepository.save(developmentProject, { data: req });
|
||||
setLogDataDiff(req, { before: null, after: record });
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
@ -295,6 +301,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
});
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
|
||||
const before = structuredClone(record);
|
||||
requestBody.status = requestBody.status.trim().toUpperCase();
|
||||
Object.assign(record, requestBody);
|
||||
|
||||
|
|
@ -302,7 +309,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await this.developmentRequestRepository.save(record);
|
||||
await this.developmentRequestRepository.save(record, { data: req });
|
||||
setLogDataDiff(req, { before, after: record });
|
||||
if (requestBody.status == "APPROVE") {
|
||||
let profileDevelopment = new ProfileDevelopment();
|
||||
const meta = {
|
||||
|
|
@ -321,7 +329,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
kpiDevelopmentId: record.id,
|
||||
developmentProjects: [],
|
||||
});
|
||||
await this.profileDevelopmentRepository.save(profileDevelopment);
|
||||
await this.profileDevelopmentRepository.save(profileDevelopment, { data: req });
|
||||
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
Object.assign(history, {
|
||||
|
|
@ -332,7 +340,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
developmentProjects: [],
|
||||
});
|
||||
history.profileDevelopmentId = profileDevelopment.id;
|
||||
await this.developmentHistoryRepository.save(history);
|
||||
await this.developmentHistoryRepository.save(history, { data: req });
|
||||
|
||||
if (record.developmentProjects != null) {
|
||||
await Promise.all(
|
||||
|
|
@ -352,8 +360,9 @@ export class DevelopmentRequestController extends Controller {
|
|||
profileDevelopmentHistoryId: history.id,
|
||||
});
|
||||
await Promise.all([
|
||||
this.developmentProjectRepository.save(developmentProject),
|
||||
this.developmentProjectRepository.save(developmentProjectHistory),
|
||||
this.developmentProjectRepository.save(developmentProject, { data: req }),
|
||||
setLogDataDiff(req, { before: null, after: developmentProject }),
|
||||
this.developmentProjectRepository.save(developmentProjectHistory, { data: req }),
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ import { AuthRole } from "../entities/AuthRole";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { request } from "axios";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { after } from "node:test";
|
||||
@Route("api/v1/org/employee/pos")
|
||||
@Tags("Employee")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -584,14 +586,15 @@ export class EmployeePositionController extends Controller {
|
|||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const before = null;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
await this.employeePosMasterRepository.save(posMaster, { data: request });
|
||||
setLogDataDiff(request, { before, after: posMaster });
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (x: any) => {
|
||||
const position = Object.assign(new EmployeePosition());
|
||||
|
|
@ -606,7 +609,7 @@ export class EmployeePositionController extends Controller {
|
|||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.employeePositionRepository.save(position);
|
||||
await this.employeePositionRepository.save(position, { data: request});
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess(posMaster.id);
|
||||
|
|
@ -796,14 +799,15 @@ export class EmployeePositionController extends Controller {
|
|||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const before = structuredClone(posMaster);
|
||||
posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
await this.employeePosMasterRepository.save(posMaster, { data: request });
|
||||
setLogDataDiff(request, { before, after: posMaster });
|
||||
await this.employeePositionRepository.delete({ posMasterId: posMaster.id });
|
||||
|
||||
await Promise.all(
|
||||
|
|
@ -820,7 +824,7 @@ export class EmployeePositionController extends Controller {
|
|||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.employeePositionRepository.save(position);
|
||||
await this.employeePositionRepository.save(position, { data: request });
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess(posMaster.id);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import { AuthRole } from "../entities/AuthRole";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { request } from "axios";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("Position")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -764,14 +765,15 @@ export class PositionController extends Controller {
|
|||
"ไม่สามารถใส่เลขที่ตำแหน่งซ้ำกันได้",
|
||||
);
|
||||
}
|
||||
|
||||
const before = null;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await this.posMasterRepository.save(posMaster, { data: request });
|
||||
setLogDataDiff(request, { before, after: posMaster });
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (x: any) => {
|
||||
const position = Object.assign(new Position());
|
||||
|
|
@ -791,7 +793,7 @@ export class PositionController extends Controller {
|
|||
position.lastUpdateFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
await this.positionRepository.save(position, { data: request });
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess(posMaster.id);
|
||||
|
|
@ -980,14 +982,15 @@ export class PositionController extends Controller {
|
|||
);
|
||||
}
|
||||
// }
|
||||
|
||||
const before = structuredClone(posMaster);
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await this.posMasterRepository.save(posMaster, { data: request });
|
||||
setLogDataDiff( request, { before, after: posMaster });
|
||||
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
||||
|
||||
await Promise.all(
|
||||
|
|
@ -1013,7 +1016,7 @@ export class PositionController extends Controller {
|
|||
position.lastUpdateFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
await this.positionRepository.save(position, { data: request });
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess(posMaster.id);
|
||||
|
|
@ -1898,6 +1901,7 @@ export class PositionController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const before = null;
|
||||
switch (requestBody.type) {
|
||||
case 0: {
|
||||
const rootId = await this.posMasterRepository.findOne({
|
||||
|
|
@ -1923,7 +1927,8 @@ export class PositionController extends Controller {
|
|||
id: data.id,
|
||||
posMasterOrder: requestBody.sortId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.posMasterRepository.save(sortData_0);
|
||||
await this.posMasterRepository.save(sortData_0, { data: request });
|
||||
setLogDataDiff(request, { before, after: sortData_0 });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1951,7 +1956,8 @@ export class PositionController extends Controller {
|
|||
id: data.id,
|
||||
posMasterOrder: requestBody.sortId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.posMasterRepository.save(sortData_1);
|
||||
await this.posMasterRepository.save(sortData_1, { data: request });
|
||||
setLogDataDiff(request, { before, after: sortData_1 });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1979,7 +1985,8 @@ export class PositionController extends Controller {
|
|||
id: data.id,
|
||||
posMasterOrder: requestBody.sortId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.posMasterRepository.save(sortData_2);
|
||||
await this.posMasterRepository.save(sortData_2, { data: request });
|
||||
setLogDataDiff(request, { before, after: sortData_2 });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2007,7 +2014,8 @@ export class PositionController extends Controller {
|
|||
id: data.id,
|
||||
posMasterOrder: requestBody.sortId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.posMasterRepository.save(sortData_3);
|
||||
await this.posMasterRepository.save(sortData_3, { data: request });
|
||||
setLogDataDiff(request, { before, after: sortData_3 });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2035,7 +2043,8 @@ export class PositionController extends Controller {
|
|||
id: data.id,
|
||||
posMasterOrder: requestBody.sortId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.posMasterRepository.save(sortData_4);
|
||||
await this.posMasterRepository.save(sortData_4, { data: request });
|
||||
setLogDataDiff(request, { before, after: sortData_4 });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2497,7 +2506,7 @@ export class PositionController extends Controller {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const before = null;
|
||||
if (change == true) {
|
||||
posMaster.posMasterOrder = maxPosMasterOrder += 1;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
|
|
@ -2506,7 +2515,8 @@ export class PositionController extends Controller {
|
|||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await this.posMasterRepository.save(posMaster, { data: request });
|
||||
setLogDataDiff(request, { before, after: posMaster });
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
@ -2986,10 +2996,11 @@ export class PositionController extends Controller {
|
|||
}
|
||||
await this.positionRepository.save(position);
|
||||
});
|
||||
|
||||
const before = null;
|
||||
dataMaster.isSit = requestBody.isSit;
|
||||
dataMaster.next_holderId = requestBody.profileId;
|
||||
await this.posMasterRepository.save(dataMaster);
|
||||
await this.posMasterRepository.save(dataMaster, { data: request });
|
||||
setLogDataDiff( request, { before, after: dataMaster });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -121,14 +122,15 @@ export class ProfileAvatarController extends Controller {
|
|||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
||||
const before = null;
|
||||
data.isActive = true;
|
||||
data.avatar = avatar;
|
||||
data.avatarName = fileName;
|
||||
await this.avatarRepository.save(data);
|
||||
await this.avatarRepository.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
profile.avatar = avatar;
|
||||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
await this.profileRepository.save(profile, { data: req });
|
||||
|
||||
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
|
||||
}
|
||||
|
|
@ -143,11 +145,11 @@ export class ProfileAvatarController extends Controller {
|
|||
_record.profileId,
|
||||
);
|
||||
}
|
||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
if (!_record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
await this.avatarRepository.remove(_record, {data: req});
|
||||
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -126,14 +127,15 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
||||
const before = null;
|
||||
data.isActive = true;
|
||||
data.avatar = avatar;
|
||||
data.avatarName = fileName;
|
||||
await this.avatarRepository.save(data);
|
||||
await this.avatarRepository.save(data, {data: req});
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
profile.avatar = avatar;
|
||||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
await this.profileRepository.save(profile, {data: req});
|
||||
|
||||
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
|
||||
}
|
||||
|
|
@ -148,11 +150,11 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
if (!_record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
await this.avatarRepository.remove(_record, {data: req});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-temp/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -127,14 +128,15 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
||||
const before = null;
|
||||
data.isActive = true;
|
||||
data.avatar = avatar;
|
||||
data.avatarName = fileName;
|
||||
await this.avatarRepository.save(data);
|
||||
await this.avatarRepository.save(data, {data: req});
|
||||
setLogDataDiff( req, {before, after: data});
|
||||
profile.avatar = avatar;
|
||||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
await this.profileRepository.save(profile, {data: req});
|
||||
|
||||
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
|
||||
}
|
||||
|
|
@ -142,11 +144,11 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
@Delete("{avatarId}")
|
||||
public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
||||
if (!_record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
await this.avatarRepository.remove(_record, { data: req});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import {
|
|||
calculateRetireLaw,
|
||||
calculateRetireYear,
|
||||
removeProfileInOrganize,
|
||||
setLogDataDiff,
|
||||
} from "../interfaces/utils";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Position } from "../entities/Position";
|
||||
|
|
@ -2535,8 +2536,8 @@ export class ProfileController extends Controller {
|
|||
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
// }
|
||||
}
|
||||
|
||||
const record = await this.profileRepo.findOneBy({ id });
|
||||
const before = structuredClone(record);
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
|
|
@ -2554,7 +2555,8 @@ export class ProfileController extends Controller {
|
|||
id: undefined,
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(record);
|
||||
await this.profileRepo.save(record, { data: request });
|
||||
setLogDataDiff(request, { before, after: record });
|
||||
|
||||
if (record != null && record.keycloak != null) {
|
||||
const result = await updateName(record.keycloak, record.firstName, record.lastName);
|
||||
|
|
@ -2575,11 +2577,11 @@ export class ProfileController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteProfile(@Path() id: string) {
|
||||
const result = await this.profileRepo.delete({ id });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
const data = await this.profileRepo.findOne({ where: { id: id } });
|
||||
if (!data) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
await this.profileRepo.remove(data);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -5740,12 +5742,13 @@ export class ProfileController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { isLeave: boolean; leaveReason?: any; dateLeave?: any },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const before = structuredClone(profile);
|
||||
const _null: any = null;
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
if (requestBody.isLeave == true) {
|
||||
|
|
@ -5761,7 +5764,8 @@ export class ProfileController extends Controller {
|
|||
} else {
|
||||
profile.dateLeave = _null;
|
||||
}
|
||||
await this.profileRepo.save(profile);
|
||||
await this.profileRepo.save(profile, { data: request });
|
||||
setLogDataDiff(request, { before, after: profile });
|
||||
// const profileSalary = await this.salaryRepository.findOne({
|
||||
// where: { profileId: id },
|
||||
// order: { createdAt: "DESC" },
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
if (req.url.startsWith("/api/v1/org/metadata/")) system="metadata";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/profile/")) system = "registry";
|
||||
if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry";
|
||||
if (req.url.startsWith("/api/v1/org/profile-temp/")) system = "registry";
|
||||
// if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
// if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue