เพิ่มฟิลด์ isSalary + api แก้ไขเงินเดือนทั้งกลุ่ม #2102
This commit is contained in:
parent
3a4e16deb0
commit
5e9189a489
3 changed files with 51 additions and 2 deletions
|
|
@ -649,6 +649,54 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @summary API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Post("tab2/edit-salary")
|
||||
async EditSalary(
|
||||
@Body()
|
||||
requestBody: {
|
||||
id: string;
|
||||
mouthSalaryAmount?: Double | null;
|
||||
positionSalaryAmount?: Double | null;
|
||||
amount?: Double | null;
|
||||
amountSpecial?: Double | null;
|
||||
remarkVertical?: string | null;
|
||||
remarkHorizontal?: string | null;
|
||||
}[],
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
|
||||
if (!Array.isArray(requestBody)) {
|
||||
throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
for (const item of requestBody) {
|
||||
if (!item.id) continue;
|
||||
|
||||
const rec = await this.commandReciveRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
|
||||
if (!rec) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||
}
|
||||
|
||||
const updated = Object.assign(rec, item);
|
||||
updated.lastUpdateUserId = request.user.sub;
|
||||
updated.lastUpdateFullName = request.user.name;
|
||||
updated.lastUpdatedAt = new Date();
|
||||
|
||||
await this.commandReciveRepository.save(updated);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบรายการผู้ได้รับคำสั่ง
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue