sort profilesalary edit
This commit is contained in:
parent
083a482b3a
commit
3f90f6cad9
1 changed files with 48 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
Post,
|
Post,
|
||||||
|
Put,
|
||||||
Query,
|
Query,
|
||||||
Request,
|
Request,
|
||||||
Route,
|
Route,
|
||||||
|
|
@ -1460,4 +1461,51 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้้ไขลำดับรายคน
|
||||||
|
*
|
||||||
|
* @summary API แก้้ไขลำดับรายคน
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("change/sort/{profileId}")
|
||||||
|
public async changeSortEdit(@Path() profileId: string) {
|
||||||
|
try {
|
||||||
|
let salaryOld = await this.salaryRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { commandDateAffect: "ASC", order: "ASC" },
|
||||||
|
});
|
||||||
|
|
||||||
|
salaryOld.forEach((item: any, i) => {
|
||||||
|
item.order = i + 1;
|
||||||
|
});
|
||||||
|
await this.salaryRepo.save(salaryOld);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
} catch {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้้ไขลำดับรายคน
|
||||||
|
*
|
||||||
|
* @summary API แก้้ไขลำดับรายคน
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("change/sort/{profileId}")
|
||||||
|
async Sort(@Path() profileId: string, @Body() requestBody: { id: string[] }) {
|
||||||
|
const salary = await this.salaryRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
});
|
||||||
|
|
||||||
|
const sortLevel = salary.map((data) => ({
|
||||||
|
...data,
|
||||||
|
id: data.id,
|
||||||
|
order: requestBody.id.indexOf(data.id) + 1,
|
||||||
|
}));
|
||||||
|
|
||||||
|
await this.salaryRepo.save(sortLevel);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue