log
This commit is contained in:
parent
4b34fc20b8
commit
1c9cb7ea78
11 changed files with 741 additions and 122 deletions
|
|
@ -25,6 +25,8 @@ import {
|
|||
} from "../entities/DevelopmentHistory";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { addLogSequence } from "../interfaces/utils";
|
||||
|
||||
@Route("api/v1/development/history/officer")
|
||||
@Tags("DevelopmentOfficerHistory")
|
||||
|
|
@ -72,7 +74,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
@Post()
|
||||
async CreateDevelopmentHistory(
|
||||
@Body() requestBody: CreateDevelopmentHistory,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const type = "OFFICER";
|
||||
const chk_name = await this.developmentHistoryRepository.find({
|
||||
|
|
@ -115,7 +117,12 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
development.createdFullName = request.user.name;
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
development.lastUpdateFullName = request.user.name;
|
||||
await this.developmentHistoryRepository.save(development);
|
||||
addLogSequence(request, {
|
||||
action: "database",
|
||||
status: "success",
|
||||
description: "Store DevelopmentHistory.",
|
||||
});
|
||||
await this.developmentHistoryRepository.save(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +137,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
async UpdateDevelopmentHistory(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateDevelopmentHistory,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const type = "OFFICER";
|
||||
const development = await this.developmentHistoryRepository.findOne({
|
||||
|
|
@ -176,7 +183,12 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
development.type = type;
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
development.lastUpdateFullName = request.user.name;
|
||||
await this.developmentHistoryRepository.save(development);
|
||||
addLogSequence(request, {
|
||||
action: "database",
|
||||
status: "success",
|
||||
description: "Store DevelopmentHistory.",
|
||||
});
|
||||
await this.developmentHistoryRepository.save(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +200,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async DeleteDevelopmentHistory(@Path() id: string) {
|
||||
async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
const type = "OFFICER";
|
||||
const development = await this.developmentHistoryRepository.findOne({
|
||||
where: { id: id, type: type },
|
||||
|
|
@ -196,8 +208,12 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
||||
}
|
||||
|
||||
await this.developmentHistoryRepository.remove(development);
|
||||
addLogSequence(request, {
|
||||
action: "database",
|
||||
status: "success",
|
||||
description: "Store DevelopmentHistory.",
|
||||
});
|
||||
await this.developmentHistoryRepository.remove(development, { data: request });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue