From fd76c6ee097ad1a0cfd186435b53f5e32b2f7737 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 5 Sep 2024 17:26:52 +0700 Subject: [PATCH] fixing response object --- src/controllers/DataOptionsController.ts | 6 ++---- src/controllers/ReportController.ts | 8 ++++---- src/controllers/SurveyController.ts | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/controllers/DataOptionsController.ts b/src/controllers/DataOptionsController.ts index 9fe41c9..86e5162 100644 --- a/src/controllers/DataOptionsController.ts +++ b/src/controllers/DataOptionsController.ts @@ -278,12 +278,10 @@ export class DataOptionController extends Controller { ...person, }; - const data = await { + return new HttpSuccess({ person: responsePerson, assign_no: assign + 1, assign_month: 6, - }; - - return new HttpSuccess({ data: data }); + }); } } diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 796e4a8..65e27dc 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -179,12 +179,12 @@ export class ReportController extends Controller { */ @Get("expand") async GetDataExpand() { - const lists = await this.personalRepository.find({ + const data = await this.personalRepository.find({ select: ["personal_id"], where: { probation_status: 7 }, }); - return new HttpSuccess(lists); + return new HttpSuccess(data); } /** @@ -556,7 +556,7 @@ export class ReportController extends Controller { * */ @Get("evaluate-commander") - async GetDataEvaluateCommander(@Query() id: string) { + async GetDataEvaluateCommander(@Query() id: string, @Request() request: RequestWithUser) { const evaluate = await this.evaluateCommanderRepository.findOne({ where: { id }, }); @@ -810,7 +810,7 @@ export class ReportController extends Controller { * */ @Get("evaluate-chairman") - async GetDataEvaluateChairman(@Query() id: string) { + async GetDataEvaluateChairman(@Query() id: string, @Request() request: RequestWithUser) { const evaluate = await this.evaluateChairmanRepository.findOne({ where: { id }, }); diff --git a/src/controllers/SurveyController.ts b/src/controllers/SurveyController.ts index cc740c1..3a471fb 100644 --- a/src/controllers/SurveyController.ts +++ b/src/controllers/SurveyController.ts @@ -36,13 +36,13 @@ export class SurveyController extends Controller { * */ @Get("") - async GetSurvey(@Query() assign_id: string, @Request() request: RequestWithUser) { - const result = await this.surveyRepository.findOne({ + async GetSurvey(@Query() assign_id: string) { + const data = await this.surveyRepository.findOne({ where: { assign_id, }, }); - return new HttpSuccess(result); + return new HttpSuccess(data); } /** @@ -58,10 +58,10 @@ export class SurveyController extends Controller { @Request() request: RequestWithUser, ) { const before = null; - const data = await { ...requestBody, personal_id: request.user.sub }; + const data = await { ...requestBody, personal_id: request.user.sub, assign_id }; await this.surveyRepository.save(data, { data: request }); setLogDataDiff(request, { before, after: data }); - return new HttpSuccess(data); + return new HttpSuccess(); } }