diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 82467001..97fdb66b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -266,6 +266,7 @@ export class CommandController extends Controller { const [commands, total] = await this.commandRepository .createQueryBuilder("command") + .leftJoinAndSelect("command.commandType", "commandType") .andWhere( new Brackets((qb) => { qb.orWhere( @@ -343,6 +344,7 @@ export class CommandController extends Controller { commandYear: _data.commandYear, commandAffectDate: _data.commandAffectDate, commandExcecuteDate: _data.commandExcecuteDate, + commandType: _data.commandType ? _data.commandType.code : null, assignFullName: null, //xxxxxxxxxxxxxxx createdFullName: _data.createdFullName, status: _data.status, diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 31c92010..ecb8c2c7 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -307,7 +307,22 @@ export class ProfileSalaryController extends Controller { }, order: { order: "ASC" }, }); - return new HttpSuccess(record); + const result = await Promise.all( + record.map(async (r) => { + let _command = null; + if (r.commandId) { + _command = await this.commandRepository.findOne({ + where: { id: r.commandId }, + relations: ["commandType"] + }); + } + return { + ...r, + commandType: _command && _command?.commandType ? _command?.commandType.code : null + }; + }) + ); + return new HttpSuccess(result); } @Get("position/user") @@ -342,7 +357,22 @@ export class ProfileSalaryController extends Controller { order: { order: "ASC" }, // order: { commandDateAffect: "ASC" }, }); - return new HttpSuccess(record); + const result = await Promise.all( + record.map(async (r) => { + let _command = null; + if (r.commandId) { + _command = await this.commandRepository.findOne({ + where: { id: r.commandId }, + relations: ["commandType"] + }); + } + return { + ...r, + commandType: _command && _command?.commandType ? _command?.commandType.code : null + }; + }) + ); + return new HttpSuccess(result); } @Get("{profileId}") @@ -361,7 +391,22 @@ export class ProfileSalaryController extends Controller { // ? `${r.positionExecutive}(${r.positionExecutiveField})` // : r.positionExecutive ?? null, // })); - return new HttpSuccess(record); + const result = await Promise.all( + record.map(async (r) => { + let _command = null; + if (r.commandId) { + _command = await this.commandRepository.findOne({ + where: { id: r.commandId }, + relations: ["commandType"] + }); + } + return { + ...r, + commandType: _command && _command?.commandType ? _command?.commandType.code : null + }; + }) + ); + return new HttpSuccess(result); } @Get("position/{profileId}") @@ -403,8 +448,22 @@ export class ProfileSalaryController extends Controller { // ? `${r.positionExecutive}(${r.positionExecutiveField})` // : r.positionExecutive ?? null, // })); - - return new HttpSuccess(record); + const result = await Promise.all( + record.map(async (r) => { + let _command = null; + if (r.commandId) { + _command = await this.commandRepository.findOne({ + where: { id: r.commandId }, + relations: ["commandType"] + }); + } + return { + ...r, + commandType: _command && _command?.commandType ? _command?.commandType.code : null + }; + }) + ); + return new HttpSuccess(result); } @Get("tenure/user")