error taos
This commit is contained in:
parent
318839c1e9
commit
181f351860
12 changed files with 2553 additions and 3182 deletions
|
|
@ -1,67 +1,47 @@
|
|||
import {
|
||||
Controller,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Survey } from "../entities/Survey";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query } from "tsoa"
|
||||
import HttpSuccess from "../interfaces/http-success"
|
||||
import HttpStatusCode from "../interfaces/http-status"
|
||||
import { RequestWithUser } from "../middlewares/user"
|
||||
import { setLogDataDiff } from "../interfaces/utils"
|
||||
import { Survey } from "../entities/Survey"
|
||||
import { AppDataSource } from "../database/data-source"
|
||||
|
||||
@Route("api/v1/probation/survey")
|
||||
@Tags("Survey")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||
export class SurveyController extends Controller {
|
||||
private surveyRepository = AppDataSource.getRepository(Survey);
|
||||
private surveyRepository = AppDataSource.getRepository(Survey)
|
||||
|
||||
/**
|
||||
* API แบบสำรวจความคิดเห็น
|
||||
*
|
||||
* @summary แบบสำรวจความคิดเห็น
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetSurvey(@Query() assign_id: string) {
|
||||
const data = await this.surveyRepository.findOne({
|
||||
where: {
|
||||
assign_id,
|
||||
},
|
||||
});
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
/**
|
||||
* API แบบสำรวจความคิดเห็น
|
||||
*
|
||||
* @summary แบบสำรวจความคิดเห็น
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetSurvey(@Query() assign_id: string) {
|
||||
const data = await this.surveyRepository.findOne({
|
||||
where: {
|
||||
assign_id,
|
||||
},
|
||||
})
|
||||
return new HttpSuccess(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกแบบสำรวจความคิดเห็น
|
||||
*
|
||||
* @summary บันทึกแบบสำรวจความคิดเห็น
|
||||
*
|
||||
*/
|
||||
@Post("")
|
||||
async PostSurvey(
|
||||
@Query() assign_id: string,
|
||||
@Body() requestBody: any,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const before = null;
|
||||
const data = await { ...requestBody, personal_id: request.user.sub, assign_id };
|
||||
await this.surveyRepository.save(data, { data: request });
|
||||
setLogDataDiff(request, { before, after: data });
|
||||
/**
|
||||
* API บันทึกแบบสำรวจความคิดเห็น
|
||||
*
|
||||
* @summary บันทึกแบบสำรวจความคิดเห็น
|
||||
*
|
||||
*/
|
||||
@Post("")
|
||||
async PostSurvey(@Query() assign_id: string, @Body() requestBody: any, @Request() request: RequestWithUser) {
|
||||
const before = null
|
||||
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();
|
||||
}
|
||||
return new HttpSuccess()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue