เช็คค่าซ้ำ

This commit is contained in:
Kittapath 2024-02-15 10:31:47 +07:00
parent 8756279309
commit d76af2c88c

View file

@ -113,21 +113,18 @@ export class PositionController extends Controller {
}
const rowRepeated = await this.posDictRepository.findOne({
where: {
posDictName: Like(`%${posDict.posDictName.trim()}%`),
posDictField: Like(`%${posDict.posDictField.trim()}%`),
where: {
posDictName: posDict.posDictName,
posDictField: posDict.posDictField,
posTypeId: posDict.posTypeId,
posLevelId: posDict.posLevelId,
posExecutiveId: String(posDict.posExecutiveId),
posDictExecutiveField: Like(`%${posDict.posDictExecutiveField.trim()}%`),
posDictArea: Like(`%${posDict.posDictArea.trim()}%`)
posDictExecutiveField: posDict.posDictExecutiveField,
posDictArea: posDict.posDictArea,
},
});
if (rowRepeated) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ข้อมูล Row นี้มีอยู่ในระบบแล้ว",
);
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
}
try {
@ -853,14 +850,14 @@ export class PositionController extends Controller {
relations: ["posLevel", "posType", "posExecutive"],
});
const profile = await this.profileRepository.findOne({
where: { id: String(posMaster.next_holderId) }
})
where: { id: String(posMaster.next_holderId) },
});
const type = await this.posTypeRepository.findOne({
where: { id: String(profile?.posTypeId) }
})
where: { id: String(profile?.posTypeId) },
});
const level = await this.posLevelRepository.findOne({
where: { id: String(profile?.posLevelId)}
})
where: { id: String(profile?.posLevelId) },
});
let shortName = "";
@ -928,9 +925,11 @@ export class PositionController extends Controller {
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
orgShortname: shortName,
isSit: posMaster.isSit,
positionNextHolder: profile == null || profile.position == null? null : profile.position,
positionNextHolder:
profile == null || profile.position == null ? null : profile.position,
postypeNextHolder: type == null || type.posTypeName == null ? null : type.posTypeName,
poslevelNextHolder: level == null || level.posLevelName == null ? null : level.posLevelName,
poslevelNextHolder:
level == null || level.posLevelName == null ? null : level.posLevelName,
positions: positions.map((position) => ({
id: position.id,
positionName: position.positionName,