This commit is contained in:
AdisakKanthawilang 2024-03-04 14:54:15 +07:00
parent 2bb68463be
commit 5e2e13d8e8
9 changed files with 12 additions and 13 deletions

View file

@ -39,7 +39,6 @@ export class GenderController extends Controller {
*/
@Get()
async GetResult() {
console.log("asds");
const _gender = await this.genderRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
@ -64,7 +63,7 @@ export class GenderController extends Controller {
select: ["id", "name"],
});
if (!_gender) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้");
}
return new HttpSuccess(_gender);
@ -84,7 +83,7 @@ export class GenderController extends Controller {
) {
const _gender = Object.assign(new Gender(), requestBody);
if (!_gender) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้");
}
const checkName = await this.genderRepository.findOne({
@ -119,7 +118,7 @@ export class GenderController extends Controller {
) {
const _gender = await this.genderRepository.findOne({ where: { id: id } });
if (!_gender) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเพศนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้");
}
const checkName = await this.genderRepository.findOne({
where: { id: Not(id), name: requestBody.name },
@ -148,7 +147,7 @@ export class GenderController extends Controller {
where: { id: id },
});
if (!_delGender) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเพศนี้");
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้");
}
await this.genderRepository.delete(_delGender.id);
return new HttpSuccess();