history update position
This commit is contained in:
parent
0df264e900
commit
910e568973
10 changed files with 625 additions and 16 deletions
|
|
@ -42,6 +42,8 @@ import { setLogDataDiff } from "../interfaces/utils";
|
|||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||
import { CreatePosMasterHistoryOfficer } from "../services/PositionService";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("Position")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -57,6 +59,7 @@ export class PositionController extends Controller {
|
|||
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
private posDictRepository = AppDataSource.getRepository(PosDict);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory);
|
||||
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
|
|
@ -1541,7 +1544,7 @@ export class PositionController extends Controller {
|
|||
// posLevelRank: "ASC",
|
||||
// },
|
||||
orderNo: "ASC",
|
||||
createdAt: "ASC"
|
||||
createdAt: "ASC",
|
||||
},
|
||||
});
|
||||
const formattedData = {
|
||||
|
|
@ -2381,7 +2384,7 @@ export class PositionController extends Controller {
|
|||
// posType: { posTypeRank: "ASC" },
|
||||
// posLevel: { posLevelRank: "ASC" },
|
||||
orderNo: "ASC",
|
||||
createdAt: "ASC"
|
||||
createdAt: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -3654,6 +3657,7 @@ export class PositionController extends Controller {
|
|||
dataMaster.current_holderId = _null;
|
||||
}
|
||||
await this.posMasterRepository.save(dataMaster, { data: request });
|
||||
await CreatePosMasterHistoryOfficer(dataMaster.id, request);
|
||||
setLogDataDiff(request, { before, after: dataMaster });
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -4826,6 +4830,7 @@ export class PositionController extends Controller {
|
|||
positionId: string;
|
||||
profileId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: body.posmasterId },
|
||||
|
|
@ -4879,8 +4884,12 @@ export class PositionController extends Controller {
|
|||
const _null: any = null;
|
||||
posMaster.conditionReason = _null;
|
||||
posMaster.isCondition = false;
|
||||
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
|
||||
if (posMasterOld != null) {
|
||||
await this.posMasterRepository.save(posMasterOld);
|
||||
await CreatePosMasterHistoryOfficer(posMasterOld.id, request);
|
||||
}
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await CreatePosMasterHistoryOfficer(posMaster.id, request);
|
||||
|
||||
const positionNew = await this.positionRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -5432,7 +5441,6 @@ export class PositionController extends Controller {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -5617,4 +5625,19 @@ export class PositionController extends Controller {
|
|||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ประวัติแก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary ประวัติแก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("history-update/{id}")
|
||||
async listPosMasterHistory(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
const posMasterHistory = await this.posMasterHistoryRepository.find({
|
||||
where: { ancestorDNA: id },
|
||||
});
|
||||
|
||||
return new HttpSuccess(posMasterHistory);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue