260326:1347 Fixing Refactor ADR-019 Naming convention uuid #01
CI / CD Pipeline / build (push) Failing after 17m29s
CI / CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
admin
2026-03-26 13:47:07 +07:00
parent 978d66e49e
commit 1aff83214f
34 changed files with 217 additions and 222 deletions
@@ -100,18 +100,20 @@ export class ContractService {
return contract;
}
async findOneByUuid(uuid: string) {
async findOneByPublicId(publicId: string) {
const contract = await this.contractRepo.findOne({
where: { uuid },
where: { publicId },
relations: ['project'],
});
if (!contract)
throw new NotFoundException(`Contract UUID ${uuid} not found`);
throw new NotFoundException(
`Contract with publicId ${publicId} not found`
);
return contract;
}
async update(uuid: string, dto: UpdateContractDto) {
const contract = await this.findOneByUuid(uuid);
async update(publicId: string, dto: UpdateContractDto) {
const contract = await this.findOneByPublicId(publicId);
if (dto.projectId) {
dto.projectId = await this.uuidResolver.resolveProjectId(dto.projectId);
}
@@ -119,8 +121,8 @@ export class ContractService {
return this.contractRepo.save(contract);
}
async remove(uuid: string) {
const contract = await this.findOneByUuid(uuid);
async remove(publicId: string) {
const contract = await this.findOneByPublicId(publicId);
return this.contractRepo.remove(contract);
}
}
@@ -4,34 +4,18 @@ import {
PrimaryGeneratedColumn,
ManyToOne,
JoinColumn,
BeforeInsert,
} from 'typeorm';
import { v7 as uuidv7 } from 'uuid';
import { Exclude, Expose } from 'class-transformer';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Exclude } from 'class-transformer';
import { UuidBaseEntity } from '../../../common/entities/uuid-base.entity';
import { Project } from '../../project/entities/project.entity';
@Entity('contracts')
export class Contract extends BaseEntity {
export class Contract extends UuidBaseEntity {
@PrimaryGeneratedColumn()
@Exclude()
id!: number;
@Expose({ name: 'id' })
@Column({
type: 'uuid',
unique: true,
nullable: false,
comment: 'UUID Public Identifier (ADR-019)',
})
uuid!: string;
@BeforeInsert()
generateUuid(): void {
if (!this.uuid) {
this.uuid = uuidv7();
}
}
// publicId inherited from UuidBaseEntity (DB column: uuid)
@Column({ name: 'project_id' })
projectId!: number;