change endPoint
This commit is contained in:
parent
5ca15d5433
commit
5812f9e56d
3 changed files with 75 additions and 6 deletions
|
|
@ -243,4 +243,39 @@ export class ProfileInsigniaController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("dump-db")
|
||||||
|
public async newInsigniaDumpDB(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) {
|
||||||
|
if (!body.profileId) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||||
|
}
|
||||||
|
|
||||||
|
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
|
||||||
|
const insignia = await this.insigniaMetaRepo.findOne({
|
||||||
|
where: { name: body.insigniaId },
|
||||||
|
});
|
||||||
|
if (!insignia) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชฯ นี้");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new ProfileInsignia();
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
createdUserId: req.user.sub,
|
||||||
|
createdFullName: req.user.name,
|
||||||
|
lastUpdateUserId: req.user.sub,
|
||||||
|
lastUpdateFullName: req.user.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
data.insigniaId = insignia.id
|
||||||
|
await this.insigniaRepo.save(data);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,4 +324,38 @@ export class ProfileLeaveController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("dump-db")
|
||||||
|
public async newLeaveDumpDB(@Request() req: RequestWithUser, @Body() body: CreateProfileLeave) {
|
||||||
|
if (!body.profileId) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||||
|
}
|
||||||
|
|
||||||
|
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
const leaveType = await this.leaveTypeRepository.findOne({
|
||||||
|
where: { name: body.leaveTypeId }
|
||||||
|
});
|
||||||
|
if (!leaveType) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทลานี้");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new ProfileLeave();
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
createdUserId: req.user.sub,
|
||||||
|
createdFullName: req.user.name,
|
||||||
|
lastUpdateUserId: req.user.sub,
|
||||||
|
lastUpdateFullName: req.user.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
data.leaveTypeId = leaveType.id;
|
||||||
|
await this.leaveRepo.save(data);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ export class ProfileChildren extends EntityBase {
|
||||||
|
|
||||||
export type CreateProfileChildren = {
|
export type CreateProfileChildren = {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
childrenCareer: string;
|
childrenCareer: string | null;
|
||||||
childrenFirstName: string;
|
childrenFirstName: string | null;
|
||||||
childrenLastName: string;
|
childrenLastName: string | null;
|
||||||
childrenPrefix: string;
|
childrenPrefix: string | null;
|
||||||
childrenLive: boolean;
|
childrenLive: boolean | null;
|
||||||
childrenCitizenId: string;
|
childrenCitizenId: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateProfileChildrenEmployee = {
|
export type CreateProfileChildrenEmployee = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue