This commit is contained in:
@@ -6,7 +6,10 @@ import {
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Unique,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Project } from '../../project/entities/project.entity';
|
||||
|
||||
@Entity('tags')
|
||||
@Unique('ux_tag_project', ['project_id', 'tag_name'])
|
||||
@@ -26,6 +29,11 @@ export class Tag {
|
||||
@Column({ type: 'text', nullable: true })
|
||||
description!: string | null; // เพิ่ม !
|
||||
|
||||
// Relations
|
||||
@ManyToOne(() => Project)
|
||||
@JoinColumn({ name: 'project_id' })
|
||||
project?: Project;
|
||||
|
||||
@CreateDateColumn()
|
||||
created_at!: Date; // เพิ่ม !
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ export class MasterService {
|
||||
}
|
||||
return this.rfaTypeRepo.find({
|
||||
where,
|
||||
relations: ['contract'],
|
||||
order: { typeCode: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -296,7 +297,9 @@ export class MasterService {
|
||||
}
|
||||
|
||||
async findAllTags(query?: SearchTagDto) {
|
||||
const qb = this.tagRepo.createQueryBuilder('tag');
|
||||
const qb = this.tagRepo
|
||||
.createQueryBuilder('tag')
|
||||
.leftJoinAndSelect('tag.project', 'project');
|
||||
|
||||
if (query?.project_id) {
|
||||
// In Tags, we use project_id (INT) directly or resolve if UUID passed via query
|
||||
|
||||
Reference in New Issue
Block a user