This commit is contained in:
AnandaTon 2024-05-13 18:07:31 +07:00
commit 5f0e3f9cf6
6 changed files with 26 additions and 10 deletions

View file

@ -33,7 +33,7 @@ import { RequestWithUser } from "../middlewares/user";
@Route("api/v1/org/profile-employee/assessments")
@Tags("ProfileEmployeeAssessments")
@Security("bearerAuth")
export class ProfileEmployeeAssessmentsController extends Controller {
export class ProfileAssessmentsEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment);
private profileAssessmentsHistoryRepository =
@ -188,7 +188,7 @@ export class ProfileEmployeeAssessmentsController extends Controller {
const result = await this.profileAssessmentsRepository.delete({ id: assessmentId });
if (result.affected && result.affected <= 0)
if (result.affected == undefined || result.affected <= 0)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess();

View file

@ -28,7 +28,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/certificate")
@Tags("ProfileEmployeeCertificate")
@Security("bearerAuth")
export class ProfileEmployeeCertificateController extends Controller {
export class ProfileCertificateEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private certificateRepo = AppDataSource.getRepository(ProfileCertificate);
private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory);
@ -171,7 +171,7 @@ export class ProfileEmployeeCertificateController extends Controller {
id: certificateId,
});
if (certificateResult.affected && certificateResult.affected <= 0) {
if (certificateResult.affected == undefined || certificateResult.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}

View file

@ -24,7 +24,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/honor")
@Tags("ProfileEmployeeHonor")
@Security("bearerAuth")
export class ProfileEmployeeHonorController extends Controller {
export class ProfileHonorEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private honorRepo = AppDataSource.getRepository(ProfileHonor);
private honorHistoryRepo = AppDataSource.getRepository(ProfileHonorHistory);
@ -162,7 +162,7 @@ export class ProfileEmployeeHonorController extends Controller {
const result = await this.honorRepo.delete({ id: honorId });
if (result.affected && result.affected <= 0) {
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}

View file

@ -29,7 +29,7 @@ import { Insignia } from "../entities/Insignia";
@Route("api/v1/org/profile-employee/insignia")
@Tags("ProfileEmployeeInsignia")
@Security("bearerAuth")
export class ProfileEmployeeInsigniaController extends Controller {
export class ProfileInsigniaEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private insigniaHistoryRepo = AppDataSource.getRepository(ProfileInsigniaHistory);
@ -220,7 +220,7 @@ export class ProfileEmployeeInsigniaController extends Controller {
const result = await this.insigniaRepo.delete({ id: insigniaId });
if (result.affected && result.affected <= 0) {
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}

View file

@ -28,7 +28,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/training")
@Tags("ProfileEmployeeTraining")
@Security("bearerAuth")
export class ProfileEmployeeTrainingController extends Controller {
export class ProfileTrainingEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private trainingRepo = AppDataSource.getRepository(ProfileTraining);
private trainingHistoryRepo = AppDataSource.getRepository(ProfileTrainingHistory);
@ -184,7 +184,7 @@ export class ProfileEmployeeTrainingController extends Controller {
const result = await this.trainingRepo.delete({ id: trainingId });
if (result.affected && result.affected <= 0) {
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileemployeeAddPk31715597418469 implements MigrationInterface {
name = 'UpdateTableProfileemployeeAddPk31715597418469'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileOther\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileOther\` ADD CONSTRAINT \`FK_b7ef3007bce554a41bdb896ed96\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileOther\` DROP FOREIGN KEY \`FK_b7ef3007bce554a41bdb896ed96\``);
await queryRunner.query(`ALTER TABLE \`profileOther\` DROP COLUMN \`profileEmployeeId\``);
}
}