ไม่เช็คประเภทคำสั่งซ้ำ

This commit is contained in:
kittapath 2024-09-20 15:02:46 +07:00
parent 395ac1161e
commit 917ca75eb2

View file

@ -143,13 +143,13 @@ export class CommandTypeController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const checkName = await this.commandTypeRepository.findOne({ // const checkName = await this.commandTypeRepository.findOne({
where: { name: requestBody.name }, // where: { name: requestBody.name },
}); // });
if (checkName) { // if (checkName) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
} // }
const checkNameSys = await this.commandSysRepository.findOne({ const checkNameSys = await this.commandSysRepository.findOne({
where: { id: requestBody.commandSysId }, where: { id: requestBody.commandSysId },
@ -187,12 +187,12 @@ export class CommandTypeController extends Controller {
if (!_commandType) { if (!_commandType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทคำสั่งชื่อนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทคำสั่งชื่อนี้");
} }
const checkName = await this.commandTypeRepository.findOne({ // const checkName = await this.commandTypeRepository.findOne({
where: { id: Not(id), name: requestBody.name }, // where: { id: Not(id), name: requestBody.name },
}); // });
if (checkName) { // if (checkName) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
} // }
const checkNameSys = await this.commandSysRepository.findOne({ const checkNameSys = await this.commandSysRepository.findOne({
where: { id: requestBody.commandSysId }, where: { id: requestBody.commandSysId },