251125:0000 Phase 6 wait start dev Check

This commit is contained in:
2025-11-25 00:28:33 +07:00
parent 553c2d13ad
commit 582ecb5741
22 changed files with 3757 additions and 489 deletions
@@ -1,5 +1,3 @@
// File: src/modules/master/dto/create-tag.dto.ts
import { IsString, IsNotEmpty, IsOptional } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
@@ -7,12 +5,9 @@ export class CreateTagDto {
@ApiProperty({ example: 'URGENT', description: 'ชื่อ Tag' })
@IsString()
@IsNotEmpty()
tag_name: string;
tag_name!: string; // เพิ่ม !
@ApiProperty({
example: 'เอกสารด่วนต้องดำเนินการทันที',
description: 'คำอธิบาย',
})
@ApiProperty({ example: 'คำอธิบาย', description: 'คำอธิบาย' })
@IsString()
@IsOptional()
description?: string;
@@ -1,5 +1,3 @@
// File: src/modules/master/entities/tag.entity.ts
import {
Entity,
Column,
@@ -11,17 +9,17 @@ import {
@Entity('tags')
export class Tag {
@PrimaryGeneratedColumn()
id: number;
id!: number; // เพิ่ม !
@Column({ length: 100, unique: true, comment: 'ชื่อ Tag' })
tag_name: string;
@Column({ length: 100, unique: true })
tag_name!: string; // เพิ่ม !
@Column({ type: 'text', nullable: true, comment: 'คำอธิบายแท็ก' })
description: string;
@Column({ type: 'text', nullable: true })
description!: string; // เพิ่ม !
@CreateDateColumn()
created_at: Date;
created_at!: Date; // เพิ่ม !
@UpdateDateColumn()
updated_at: Date;
updated_at!: Date; // เพิ่ม !
}
+13 -18
View File
@@ -49,15 +49,15 @@ export class MasterService {
async findAllCorrespondenceTypes() {
return this.corrTypeRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
async findAllCorrespondenceStatuses() {
return this.corrStatusRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
@@ -67,22 +67,22 @@ export class MasterService {
async findAllRfaTypes() {
return this.rfaTypeRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
async findAllRfaStatuses() {
return this.rfaStatusRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
async findAllRfaApproveCodes() {
return this.rfaApproveRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
@@ -92,8 +92,8 @@ export class MasterService {
async findAllCirculationStatuses() {
return this.circulationStatusRepo.find({
where: { is_active: true },
order: { sort_order: 'ASC' },
where: { isActive: true }, // ✅ แก้เป็น camelCase
order: { sortOrder: 'ASC' }, // ✅ แก้เป็น camelCase
});
}
@@ -101,9 +101,6 @@ export class MasterService {
// 🏷️ Tag Management (CRUD)
// =================================================================
/**
* ค้นหา Tag ทั้งหมด พร้อมรองรับการ Search และ Pagination
*/
async findAllTags(query?: SearchTagDto) {
const qb = this.tagRepo.createQueryBuilder('tag');
@@ -115,14 +112,12 @@ export class MasterService {
qb.orderBy('tag.tag_name', 'ASC');
// Pagination Logic
if (query?.page && query?.limit) {
const page = query.page;
const limit = query.limit;
qb.skip((page - 1) * limit).take(limit);
}
// ถ้ามีการแบ่งหน้า ให้ส่งคืนทั้งข้อมูลและจำนวนทั้งหมด (count)
if (query?.page && query?.limit) {
const [items, total] = await qb.getManyAndCount();
return {
@@ -153,7 +148,7 @@ export class MasterService {
}
async updateTag(id: number, dto: UpdateTagDto) {
const tag = await this.findOneTag(id); // Reuse findOne for check
const tag = await this.findOneTag(id);
Object.assign(tag, dto);
return this.tagRepo.save(tag);
}