47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import {
|
|
Controller,
|
|
Route,
|
|
Security,
|
|
Tags,
|
|
Request,
|
|
SuccessResponse,
|
|
Response,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
} from "tsoa";
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
import HttpStatusCode from "../interfaces/http-status";
|
|
import { RequestWithUser } from "../middlewares/user";
|
|
import { findEndDate } from "../interfaces/utils";
|
|
|
|
@Route("api/v1/probation/calculate")
|
|
@Tags("ฟอร์มมอบหมายงาน")
|
|
@Security("bearerAuth")
|
|
@Response(
|
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
)
|
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
export class CalculateController extends Controller {
|
|
/**
|
|
* API คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา
|
|
*
|
|
* @summary คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา
|
|
*
|
|
*/
|
|
@Post("assign-finish")
|
|
async AssignFinish(
|
|
@Body()
|
|
requestBody: {
|
|
month: number;
|
|
start_date: Date;
|
|
},
|
|
@Request() request: RequestWithUser,
|
|
) {
|
|
const { month, start_date } = requestBody;
|
|
const finish_date = findEndDate(month, start_date);
|
|
|
|
return new HttpSuccess({ finish_date });
|
|
}
|
|
}
|