no message
This commit is contained in:
parent
ff49b53713
commit
c0bfd46fc3
4 changed files with 365 additions and 122 deletions
|
|
@ -41,6 +41,7 @@ import permission from "../interfaces/permission";
|
|||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("Position")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -56,8 +57,10 @@ export class PositionController extends Controller {
|
|||
private posLevelEmployeeRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||
private posDictRepository = AppDataSource.getRepository(PosDict);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
private profileEmployeeRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
|
|
@ -3587,6 +3590,7 @@ export class PositionController extends Controller {
|
|||
.leftJoinAndSelect("positions.posType", "posType")
|
||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.andWhere("posMaster.next_holderId IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
|
|
@ -3841,6 +3845,7 @@ export class PositionController extends Controller {
|
|||
.leftJoinAndSelect("positions.posType", "posType")
|
||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.andWhere("posMaster.next_holderId IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
|
|
@ -4799,4 +4804,218 @@ export class PositionController extends Controller {
|
|||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("officer/master/book")
|
||||
async posMasterBookOfficer(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
profileId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
|
||||
posMaster.next_holderId = requestBody.profileId;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("officer/master/clear")
|
||||
async posMasterClearOfficer(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
posMaster.next_holderId = null;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("employee/master/book")
|
||||
async posMasterBookEmployee(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
profileId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
const profile = await this.profileEmployeeRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
|
||||
posMaster.next_holderId = requestBody.profileId;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("employee/master/clear")
|
||||
async posMasterClearEmployee(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
posMaster.next_holderId = null;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("officer/master-old/book")
|
||||
async posMasterOldBookOfficer(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
posMasterOldId: string;
|
||||
profileId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
|
||||
posMaster.next_holderId = requestBody.profileId;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
if (requestBody.posMasterOldId != null) {
|
||||
const posMasterOld = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterOldId },
|
||||
});
|
||||
if (!posMasterOld) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
posMasterOld.next_holderId = null;
|
||||
posMasterOld.lastUpdateUserId = request.user.sub;
|
||||
posMasterOld.lastUpdateFullName = request.user.name;
|
||||
posMasterOld.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMasterOld);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่ง
|
||||
*
|
||||
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("employee/master-old/book")
|
||||
async posMasterOldBookEmployee(
|
||||
@Body()
|
||||
requestBody: {
|
||||
posMasterId: string;
|
||||
posMasterOldId: string;
|
||||
profileId: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterId },
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
const profile = await this.profileEmployeeRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
|
||||
posMaster.next_holderId = requestBody.profileId;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
|
||||
if (requestBody.posMasterOldId != null) {
|
||||
const posMasterOld = await this.employeePosMasterRepository.findOne({
|
||||
where: { id: requestBody.posMasterOldId },
|
||||
});
|
||||
if (!posMasterOld) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
posMasterOld.next_holderId = null;
|
||||
posMasterOld.lastUpdateUserId = request.user.sub;
|
||||
posMasterOld.lastUpdateFullName = request.user.name;
|
||||
posMasterOld.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMasterOld);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue