This commit is contained in:
AdisakKanthawilang 2024-08-09 14:17:24 +07:00
parent 8e82201fbd
commit 1736f5043e
7 changed files with 147 additions and 30 deletions

View file

@ -23,6 +23,8 @@ import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import { SalaryRanks } from "../entities/SalaryRanks";
import { randomUUID } from "crypto";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
@Route("api/v1/salary")
@Tags("Salary")
@ -50,10 +52,8 @@ export class SalaryController extends Controller {
endDate: "datetime", //วันที่สิ้นสุดบังคับใช้
detail: "string", //คำอธิบาย
})
async create_salary(
@Body() requestBody: CreateSalary,
@Request() request: { user: Record<string, any> },
) {
async create_salary(@Body() requestBody: CreateSalary, @Request() request: RequestWithUser) {
await new permission().PermissionCreate(request, "SYS_SALARY_CHART_OFFICER");
const salarys = Object.assign(new Salarys(), requestBody);
if (!salarys) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
@ -126,8 +126,9 @@ export class SalaryController extends Controller {
async update_salary(
@Path() id: string,
@Body() requestBody: UpdateSalary,
@Request() request: { user: Record<string, any> },
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_SALARY_CHART_OFFICER");
const chk_Salary = await this.salaryRepository.findOne({
where: { id: id },
});
@ -206,7 +207,8 @@ export class SalaryController extends Controller {
* @param {string} id Guid, *Id
*/
@Delete("{id}")
async delete_salary(@Path() id: string) {
async delete_salary(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_SALARY_CHART_OFFICER");
const chk_Salary = await this.salaryRepository.findOne({
where: { id: id },
});
@ -327,8 +329,9 @@ export class SalaryController extends Controller {
@Post("copy")
async copySalary(
@Body() body: { id: string },
@Request() request: { user: Record<string, any> },
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_SALARY_CHART_OFFICER");
const salary = await this.salaryRepository.findOne({
relations: ["posLevel_", "posType_", "salaryRanks_"],
where: { id: body.id },