ค้นหาลำดับโครงสร้าง

This commit is contained in:
mamoss 2025-03-27 03:18:00 +07:00
parent 6a4f032b01
commit 068dabe792

View file

@ -36,6 +36,8 @@ import { EmployeePosition } from "../entities/EmployeePosition";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
import { AuthRole } from "../entities/AuthRole";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
@Route("api/v1/org")
@Tags("Organization")
@ -60,6 +62,8 @@ export class OrganizationController extends Controller {
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
/**
* API
@ -152,14 +156,17 @@ export class OrganizationController extends Controller {
data: {
requestBody: requestBody,
request: request.user,
revision: revision
revision: revision,
},
}
};
try {
await sendToQueueOrgDraft(msg);
return new HttpSuccess ('Draft is being created... Processing in the background.');
} catch (error:any) {
return new HttpError (HttpStatusCode.NOT_FOUND,'Failed to process the draft. Please try again later.');
return new HttpSuccess("Draft is being created... Processing in the background.");
} catch (error: any) {
return new HttpError(
HttpStatusCode.NOT_FOUND,
"Failed to process the draft. Please try again later.",
);
}
}
@ -7544,4 +7551,34 @@ export class OrganizationController extends Controller {
});
}
}
/**
* API
*
* @summary - (ADMIN)
*
*/
@Get("root/search/sort")
async searchSortRootLevelType(@Request() request: RequestWithUser) {
const root = await this.orgRootRepository.find({
where: {
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
order: { orgRootOrder: "ASC" },
select: ["orgRootName"],
});
const posType = await this.posTypeRepository.find({
order: { posTypeRank: "ASC" },
select: ["posTypeName"],
});
const posLevel = await this.posLevelRepository.find({
order: { posLevelRank: "ASC" },
select: ["posLevelName"],
});
return new HttpSuccess({
root: root,
posTypeNameOrder: posType,
posLevelNameOrder: posLevel,
});
}
}