update national code
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-26 14:29:25 +03:30
parent aef712ca1d
commit 7f78691f91
@@ -135,6 +135,7 @@ export class CustomersService {
password, password,
phone, phone,
birthDate, birthDate,
nationalCode,
}; };
// const addressUpdateData = { // const addressUpdateData = {
@@ -169,7 +170,7 @@ export class CustomersService {
if (nationalCode) { if (nationalCode) {
const existingNationalCode = await queryRunner.manager.findOne(this.realUserRepository.target, { const existingNationalCode = await queryRunner.manager.findOne(this.realUserRepository.target, {
where: { nationalCode: nationalCode, id: Not(user.id) }, where: { nationalCode: nationalCode, user: { id: Not(user.id) } },
}); });
if (existingNationalCode) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST); if (existingNationalCode) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
} }
@@ -180,6 +181,15 @@ export class CustomersService {
await queryRunner.manager.update(this.userRepository.target, { id: customerId }, { password: hashPassword }); await queryRunner.manager.update(this.userRepository.target, { id: customerId }, { password: hashPassword });
} }
if (nationalCode) {
const realUser = await queryRunner.manager.findOne(this.realUserRepository.target, {
where: { user: { id: customerId } },
});
if (realUser) {
await queryRunner.manager.update(this.realUserRepository.target, { id: realUser.id }, { nationalCode });
}
}
const hasLegalUpdateData = Boolean( const hasLegalUpdateData = Boolean(
registrationName || economicCode || nationalIdentity || registrationCode || postalCode || address || cityId, registrationName || economicCode || nationalIdentity || registrationCode || postalCode || address || cityId,
); );