เพิ่ม promose all ก่อน return

This commit is contained in:
kittapath 2024-08-16 10:11:36 +07:00
parent 0272361d36
commit c5ca718b9f
2 changed files with 61 additions and 63 deletions

View file

@ -46,11 +46,8 @@ export class kpiLinkController extends Controller {
* @returns
*/
@Post()
async createKpiLink(
@Body() requestBody: createKpiLink,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
async createKpiLink(@Body() requestBody: createKpiLink, @Request() request: RequestWithUser) {
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
const chkkpiGroup = await this.kpiGroupRepository.findOne({
where: {
id: requestBody.kpiGroupId,
@ -71,7 +68,7 @@ export class kpiLinkController extends Controller {
await this.kpiLinkRepository.save(kpiLink);
if (requestBody.positions != null) {
Promise.all(
await Promise.all(
requestBody.positions.map(async (positionName) => {
let position = new Position();
position.name = positionName;
@ -110,7 +107,7 @@ export class kpiLinkController extends Controller {
@Body() requestBody: createKpiLink,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
const chkKpiLink = await this.kpiLinkRepository.findOne({
where: {
id: id,
@ -134,7 +131,7 @@ export class kpiLinkController extends Controller {
chkKpiLink.lastUpdateFullName = request.user.name;
if (requestBody.positions != null) {
Promise.all(
await Promise.all(
requestBody.positions.map(async (positionName) => {
let position = new Position();
position.name = positionName;
@ -203,7 +200,7 @@ export class kpiLinkController extends Controller {
*/
@Delete("{id}")
async deleteKpiLink(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
const kpiLink = await this.kpiLinkRepository.findOne({
where: { id: id },
relations: ["kpiCapacitys"],