noti admin

This commit is contained in:
kittapath 2024-11-12 16:51:06 +07:00
parent 07e1a94da0
commit 8d5b125dd0

View file

@ -69,6 +69,7 @@ import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHisto
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import { viewDirector } from "../entities/view/viewDirector";
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
import CallAPI from "../interfaces/call-api";
@Route("api/v1/org/profile")
@Tags("Profile")
@Security("bearerAuth")
@ -228,20 +229,23 @@ export class ProfileController extends Controller {
where: { profileId: id },
order: { lastUpdatedAt: "DESC" },
});
const Education = educations && educations.length > 0
? educations.map((item) => ({
institute: item.institute ? item.institute : "-",
date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: "-",
degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
}))
: [{
institute: "-",
date: "-",
degree: "-",
}]
const Education =
educations && educations.length > 0
? educations.map((item) => ({
institute: item.institute ? item.institute : "-",
date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: "-",
degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
}))
: [
{
institute: "-",
date: "-",
degree: "-",
},
];
const mapData = {
// Id: profile.id,
@ -7874,4 +7878,42 @@ export class ProfileController extends Controller {
]);
return new HttpSuccess();
}
@Post("state-next")
public async stateNext(
@Request() req: RequestWithUser,
@Body()
body: {
subject: string;
body: string;
},
) {
if (!req.user.role.includes("SUPER_ADMIN"))
throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ส่งข้อความ");
const profileNoti = await this.profileRepo.find({
where: {
roleKeycloaks: {
name: "ADMIN",
},
},
});
profileNoti.map((x) => ({
receiverUserId: x.id,
notiLink: "",
}));
await new CallAPI()
.PostData(req, "/placement/noti/profiles", {
subject: body.subject,
body: body.body,
receiverUserIds: profileNoti,
payload: "", //แนบไฟล์
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
})
.catch((error) => {
console.error("Error calling API:", error);
});
return new HttpSuccess();
}
}