Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
291d3199d2
8 changed files with 37 additions and 19 deletions
|
|
@ -724,6 +724,7 @@ export class OrganizationController extends Controller {
|
||||||
orgTreeFax: orgRoot.orgRootFax,
|
orgTreeFax: orgRoot.orgRootFax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||||
totalPosition: await this.posMasterRepository.count({
|
totalPosition: await this.posMasterRepository.count({
|
||||||
|
|
@ -833,6 +834,7 @@ export class OrganizationController extends Controller {
|
||||||
orgTreeFax: orgChild1.orgChild1Fax,
|
orgTreeFax: orgChild1.orgChild1Fax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild1.orgChild1Name +
|
orgChild1.orgChild1Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
@ -947,6 +949,7 @@ export class OrganizationController extends Controller {
|
||||||
orgTreeFax: orgChild2.orgChild2Fax,
|
orgTreeFax: orgChild2.orgChild2Fax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild2.orgChild2Name +
|
orgChild2.orgChild2Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
@ -1064,6 +1067,7 @@ export class OrganizationController extends Controller {
|
||||||
orgTreeFax: orgChild3.orgChild3Fax,
|
orgTreeFax: orgChild3.orgChild3Fax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild3.orgChild3Name +
|
orgChild3.orgChild3Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
@ -1181,6 +1185,7 @@ export class OrganizationController extends Controller {
|
||||||
orgTreeFax: orgChild4.orgChild4Fax,
|
orgTreeFax: orgChild4.orgChild4Fax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild4.orgChild4Name +
|
orgChild4.orgChild4Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ export class ProfileNopaidController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{nopaidId}")
|
@Delete("{nopaidId}")
|
||||||
public async deleteTraning(@Path() nopaidId: string) {
|
public async deleteNopaid(@Path() nopaidId: string) {
|
||||||
await this.nopaidHistoryRepository.delete({
|
await this.nopaidHistoryRepository.delete({
|
||||||
profileNopaidId: nopaidId,
|
profileNopaidId: nopaidId,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{nopaidId}")
|
@Delete("{nopaidId}")
|
||||||
public async deleteTraning(@Path() nopaidId: string) {
|
public async deleteNopaid(@Path() nopaidId: string) {
|
||||||
await this.nopaidHistoryRepository.delete({
|
await this.nopaidHistoryRepository.delete({
|
||||||
profileNopaidId: nopaidId,
|
profileNopaidId: nopaidId,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@ import {
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import {
|
import {
|
||||||
CreateProfileSalaryEmployee,
|
CreateProfileSalaryEmployee,
|
||||||
ProfileSalary,
|
ProfileSalaryEmployee,
|
||||||
UpdateProfileSalary,
|
UpdateProfileSalaryEmployee,
|
||||||
} from "../entities/ProfileSalary";
|
} from "../entities/ProfileSalaryEmployee";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
import { LessThan, MoreThan } from "typeorm";
|
import { LessThan, MoreThan } from "typeorm";
|
||||||
|
|
||||||
|
|
@ -32,13 +31,13 @@ import { LessThan, MoreThan } from "typeorm";
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
export class ProfileSalaryEmployeeController extends Controller {
|
export class ProfileSalaryEmployeeController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
|
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
private salaryRepo = AppDataSource.getRepository(ProfileSalaryEmployee);
|
||||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
public async getSalary(@Path() profileId: string) {
|
public async getSalary(@Path() profileId: string) {
|
||||||
const record = await this.salaryRepo.find({
|
const record = await this.salaryRepo.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileId: profileId },
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -57,22 +56,22 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: CreateProfileSalaryEmployee,
|
@Body() body: CreateProfileSalaryEmployee,
|
||||||
) {
|
) {
|
||||||
if (!body.profileEmployeeId) {
|
if (!body.profileId) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
|
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||||
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
|
||||||
const dest_item = await this.salaryRepo.findOne({
|
const dest_item = await this.salaryRepo.findOne({
|
||||||
where: { profileId: body.profileEmployeeId },
|
where: { profileId: body.profileId },
|
||||||
order: { order: "DESC" },
|
order: { order: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalaryEmployee();
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
order: dest_item == null ? 1 : dest_item.order + 1,
|
order: dest_item == null ? 1 : dest_item.order + 1,
|
||||||
|
|
@ -92,7 +91,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
@Patch("{salaryId}")
|
@Patch("{salaryId}")
|
||||||
public async editSalary(
|
public async editSalary(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: UpdateProfileSalary,
|
@Body() body: UpdateProfileSalaryEmployee,
|
||||||
@Path() salaryId: string,
|
@Path() salaryId: string,
|
||||||
) {
|
) {
|
||||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import { ProfileEducation } from "./ProfileEducation";
|
||||||
import { ProfileAbility } from "./ProfileAbility";
|
import { ProfileAbility } from "./ProfileAbility";
|
||||||
import { ProfileOther } from "./ProfileOther";
|
import { ProfileOther } from "./ProfileOther";
|
||||||
import { ProfileAvatar } from "./ProfileAvatar";
|
import { ProfileAvatar } from "./ProfileAvatar";
|
||||||
|
import { ProfileGovernment } from "./ProfileGovernment";
|
||||||
@Entity("profileEmployee")
|
@Entity("profileEmployee")
|
||||||
export class ProfileEmployee extends EntityBase {
|
export class ProfileEmployee extends EntityBase {
|
||||||
@Column({
|
@Column({
|
||||||
|
|
@ -243,7 +244,7 @@ export class ProfileEmployee extends EntityBase {
|
||||||
profileNopaids: ProfileNopaid[];
|
profileNopaids: ProfileNopaid[];
|
||||||
|
|
||||||
@OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee)
|
@OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee)
|
||||||
profileDisciplines: ProfileNopaid[];
|
profileDisciplines: ProfileDiscipline[];
|
||||||
|
|
||||||
@OneToMany(() => ProfileChangeName, (v) => v.profileEmployee)
|
@OneToMany(() => ProfileChangeName, (v) => v.profileEmployee)
|
||||||
profileChangeNames: ProfileChangeName[];
|
profileChangeNames: ProfileChangeName[];
|
||||||
|
|
@ -274,6 +275,9 @@ export class ProfileEmployee extends EntityBase {
|
||||||
|
|
||||||
@OneToMany(() => ProfileEmployeeHistory, (v) => v.profileEmployee)
|
@OneToMany(() => ProfileEmployeeHistory, (v) => v.profileEmployee)
|
||||||
histories: ProfileEmployeeHistory[];
|
histories: ProfileEmployeeHistory[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProfileGovernment, (v) => v.profileEmployee)
|
||||||
|
profileGovernment: ProfileGovernment[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity("profileEmployeeHistory")
|
@Entity("profileEmployeeHistory")
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ export class ProfileGovernment extends EntityBase {
|
||||||
@JoinColumn({ name: "profileId" })
|
@JoinColumn({ name: "profileId" })
|
||||||
profile: Profile;
|
profile: Profile;
|
||||||
|
|
||||||
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileTrainings)
|
@ManyToOne(() => ProfileEmployee, (v) => v.profileGovernment)
|
||||||
@JoinColumn({ name: "profileEmployeeId" })
|
@JoinColumn({ name: "profileEmployeeId" })
|
||||||
profileEmployee: ProfileEmployee;
|
profileEmployee: ProfileEmployee;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,10 +146,6 @@ export class ProfileSalary extends EntityBase {
|
||||||
@ManyToOne(() => Profile, (profile) => profile.profileSalary)
|
@ManyToOne(() => Profile, (profile) => profile.profileSalary)
|
||||||
@JoinColumn({ name: "profileId" })
|
@JoinColumn({ name: "profileId" })
|
||||||
profile: Profile;
|
profile: Profile;
|
||||||
|
|
||||||
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileSalary)
|
|
||||||
@JoinColumn({ name: "profileEmployeeId" })
|
|
||||||
profileEmployee: ProfileEmployee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfileSalary {
|
export class CreateProfileSalary {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableNodeAddResponsibilit11715679161554 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableNodeAddResponsibilit11715679161554'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_f5758428d496b6d2a051c8af92b\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_f5758428d496b6d2a051c8af92b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue