Merge branch 'develop' into adiDev
This commit is contained in:
commit
40205a3a97
34 changed files with 442 additions and 326 deletions
|
|
@ -724,6 +724,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeFax: orgRoot.orgRootFax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||
totalPosition: await this.posMasterRepository.count({
|
||||
|
|
@ -833,6 +834,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeFax: orgChild1.orgChild1Fax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgChild1.orgChild1Name +
|
||||
" " +
|
||||
|
|
@ -947,6 +949,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeFax: orgChild2.orgChild2Fax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgChild2.orgChild2Name +
|
||||
" " +
|
||||
|
|
@ -1064,6 +1067,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeFax: orgChild3.orgChild3Fax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgChild3.orgChild3Name +
|
||||
" " +
|
||||
|
|
@ -1181,6 +1185,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeFax: orgChild4.orgChild4Fax,
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootName: orgRoot.orgRootName,
|
||||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgChild4.orgChild4Name +
|
||||
" " +
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where({
|
||||
|
|
@ -219,7 +219,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
@ -278,7 +278,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("employeePosMaster.positions", "positions")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where({
|
||||
|
|
@ -426,7 +426,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
|
|||
64
src/controllers/ProfileAvatarController.ts
Normal file
64
src/controllers/ProfileAvatarController.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { Body, Controller, Delete, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||
|
||||
@Route("api/v1/org/profile/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
export class ProfileAvatarController extends Controller {
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getAvatar(@Path() profileId: string) {
|
||||
const lists = await this.avatarRepository.find({
|
||||
where: { profileId: profileId },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) {
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const data = new ProfileAvatar();
|
||||
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
||||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-${data.id}`;
|
||||
data.avatar = avatar;
|
||||
await this.avatarRepository.save(data);
|
||||
profile.avatar = avatar;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
return new HttpSuccess(avatar);
|
||||
}
|
||||
|
||||
@Delete("{avatarId}")
|
||||
public async deleteAvatar(@Path() avatarId: string) {
|
||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
67
src/controllers/ProfileAvatarEmployeeController.ts
Normal file
67
src/controllers/ProfileAvatarEmployeeController.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Body, Controller, Delete, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
||||
@Route("api/v1/org/profile-employee/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
export class ProfileAvatarEmployeeController extends Controller {
|
||||
private profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getAvatar(@Path() profileId: string) {
|
||||
const lists = await this.avatarRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newAvatar(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileEmployeeAvatar,
|
||||
) {
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const data = new ProfileAvatar();
|
||||
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
||||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-employee-${data.id}`;
|
||||
data.avatar = avatar;
|
||||
await this.avatarRepository.save(data);
|
||||
profile.avatar = avatar;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
return new HttpSuccess(avatar);
|
||||
}
|
||||
|
||||
@Delete("{avatarId}")
|
||||
public async deleteAvatar(@Path() avatarId: string) {
|
||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ export class ProfileController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
@Body() body: CreateProfileAllFields,
|
||||
) {
|
||||
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId })
|
||||
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId });
|
||||
if (profileExist) {
|
||||
return new HttpSuccess(profileExist.id);
|
||||
}
|
||||
|
|
@ -759,11 +759,11 @@ export class ProfileController extends Controller {
|
|||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
||||
|
||||
const position = await this.positionRepository.findOne({
|
||||
const position = await this.positionRepository.findOne({
|
||||
relations: ["posExecutive"],
|
||||
where: {
|
||||
posMasterId: posMaster?.id
|
||||
}
|
||||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
|
|
@ -781,15 +781,16 @@ export class ProfileController extends Controller {
|
|||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||
posExecutiveName: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.id,
|
||||
posExecutiveName:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId:
|
||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||
rootId:
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
|
||||
|
|
@ -1729,7 +1730,7 @@ export class ProfileController extends Controller {
|
|||
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where((qb) => {
|
||||
|
|
@ -1890,7 +1891,7 @@ export class ProfileController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
@ -1937,14 +1938,14 @@ export class ProfileController extends Controller {
|
|||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevisionId: revisionId
|
||||
}
|
||||
orgRevisionId: revisionId,
|
||||
},
|
||||
});
|
||||
const position = await this.positionRepository.findOne({
|
||||
const position = await this.positionRepository.findOne({
|
||||
relations: ["posExecutive"],
|
||||
where: {
|
||||
posMasterId: posMaster?.id
|
||||
}
|
||||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const _profile = {
|
||||
|
|
@ -1961,15 +1962,16 @@ export class ProfileController extends Controller {
|
|||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||
posExecutiveName: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.id,
|
||||
posExecutiveName:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId:
|
||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||
rootId:
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ export class ProfileDisciplineController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteTraning(@Path() disciplineId: string) {
|
||||
public async deleteDiscipline(@Path() disciplineId: string) {
|
||||
await this.disciplineHistoryRepository.delete({
|
||||
profileDisciplineId: disciplineId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteTraning(@Path() disciplineId: string) {
|
||||
public async deleteDiscipline(@Path() disciplineId: string) {
|
||||
await this.disciplineHistoryRepository.delete({
|
||||
profileDisciplineId: disciplineId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export class ProfileDutyController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteTraning(@Path() dutyId: string) {
|
||||
public async deleteDuty(@Path() dutyId: string) {
|
||||
await this.dutyHistoryRepository.delete({
|
||||
profileDutyId: dutyId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteTraning(@Path() dutyId: string) {
|
||||
public async deleteDuty(@Path() dutyId: string) {
|
||||
await this.dutyHistoryRepository.delete({
|
||||
profileDutyId: dutyId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -975,7 +975,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("employeePosMaster.positions", "positions")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where((qb) => {
|
||||
|
|
@ -1128,7 +1128,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
|
|||
|
|
@ -114,34 +114,34 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary เพิ่มข้อมูลราชการ
|
||||
*
|
||||
*/
|
||||
@Post()
|
||||
public async newGov(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeGovernment) {
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
// /**
|
||||
// *
|
||||
// * @summary เพิ่มข้อมูลราชการ
|
||||
// *
|
||||
// */
|
||||
// @Post()
|
||||
// public async newGov(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeGovernment) {
|
||||
// if (!body.profileEmployeeId) {
|
||||
// throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
// }
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
// const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
// if (!profile) {
|
||||
// throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
// }
|
||||
|
||||
const data = new ProfileGovernment();
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
// const data = new ProfileGovernment();
|
||||
// const meta = {
|
||||
// createdUserId: req.user.sub,
|
||||
// createdFullName: req.user.name,
|
||||
// lastUpdateUserId: req.user.sub,
|
||||
// lastUpdateFullName: req.user.name,
|
||||
// };
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
await this.govRepo.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
// Object.assign(data, { ...body, ...meta });
|
||||
// await this.govRepo.save(data);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -172,17 +172,17 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ลบข้อมูลราชการ
|
||||
*
|
||||
*/
|
||||
@Delete("{profileEmployeeId}")
|
||||
public async deleteGov(@Path() profileEmployeeId: string) {
|
||||
const result = await this.govRepo.delete({ profileEmployeeId: profileEmployeeId });
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
// /**
|
||||
// *
|
||||
// * @summary ลบข้อมูลราชการ
|
||||
// *
|
||||
// */
|
||||
// @Delete("{profileEmployeeId}")
|
||||
// public async deleteGov(@Path() profileEmployeeId: string) {
|
||||
// const result = await this.govRepo.delete({ profileEmployeeId: profileEmployeeId });
|
||||
// if (result.affected == undefined || result.affected <= 0) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
// }
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ export class ProfileLeaveController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteTraning(@Path() leaveId: string) {
|
||||
public async deleteLeave(@Path() leaveId: string) {
|
||||
await this.leaveHistoryRepo.delete({
|
||||
profileLeaveId: leaveId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteTraning(@Path() leaveId: string) {
|
||||
public async deleteLeave(@Path() leaveId: string) {
|
||||
await this.leaveHistoryRepo.delete({
|
||||
profileLeaveId: leaveId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ export class ProfileNopaidController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{nopaidId}")
|
||||
public async deleteTraning(@Path() nopaidId: string) {
|
||||
public async deleteNopaid(@Path() nopaidId: string) {
|
||||
await this.nopaidHistoryRepository.delete({
|
||||
profileNopaidId: nopaidId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{nopaidId}")
|
||||
public async deleteTraning(@Path() nopaidId: string) {
|
||||
public async deleteNopaid(@Path() nopaidId: string) {
|
||||
await this.nopaidHistoryRepository.delete({
|
||||
profileNopaidId: nopaidId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ export class ProfileOtherController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteTraning(@Path() otherId: string) {
|
||||
public async deleteOther(@Path() otherId: string) {
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteTraning(@Path() otherId: string) {
|
||||
public async deleteOther(@Path() otherId: string) {
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,15 +15,14 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import {
|
||||
CreateProfileSalaryEmployee,
|
||||
ProfileSalary,
|
||||
UpdateProfileSalary,
|
||||
} from "../entities/ProfileSalary";
|
||||
ProfileSalaryEmployee,
|
||||
UpdateProfileSalaryEmployee,
|
||||
} from "../entities/ProfileSalaryEmployee";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
|
||||
|
|
@ -32,13 +31,13 @@ import { LessThan, MoreThan } from "typeorm";
|
|||
@Security("bearerAuth")
|
||||
export class ProfileSalaryEmployeeController extends Controller {
|
||||
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||
private salaryRepo = AppDataSource.getRepository(ProfileSalaryEmployee);
|
||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getSalary(@Path() profileId: string) {
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
where: { profileId: profileId },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -57,22 +56,22 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileSalaryEmployee,
|
||||
) {
|
||||
if (!body.profileEmployeeId) {
|
||||
if (!body.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) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const dest_item = await this.salaryRepo.findOne({
|
||||
where: { profileId: body.profileEmployeeId },
|
||||
where: { profileId: body.profileId },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
|
||||
const data = new ProfileSalary();
|
||||
const data = new ProfileSalaryEmployee();
|
||||
|
||||
const meta = {
|
||||
order: dest_item == null ? 1 : dest_item.order + 1,
|
||||
|
|
@ -92,7 +91,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Patch("{salaryId}")
|
||||
public async editSalary(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: UpdateProfileSalary,
|
||||
@Body() body: UpdateProfileSalaryEmployee,
|
||||
@Path() salaryId: string,
|
||||
) {
|
||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue