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 { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import { viewDirector } from "../entities/view/viewDirector"; import { viewDirector } from "../entities/view/viewDirector";
import { viewDirectorActing } from "../entities/view/viewDirectorActing"; import { viewDirectorActing } from "../entities/view/viewDirectorActing";
import CallAPI from "../interfaces/call-api";
@Route("api/v1/org/profile") @Route("api/v1/org/profile")
@Tags("Profile") @Tags("Profile")
@Security("bearerAuth") @Security("bearerAuth")
@ -228,7 +229,8 @@ export class ProfileController extends Controller {
where: { profileId: id }, where: { profileId: id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
const Education = educations && educations.length > 0 const Education =
educations && educations.length > 0
? educations.map((item) => ({ ? educations.map((item) => ({
institute: item.institute ? item.institute : "-", institute: item.institute ? item.institute : "-",
date: date:
@ -237,11 +239,13 @@ export class ProfileController extends Controller {
: "-", : "-",
degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
})) }))
: [{ : [
{
institute: "-", institute: "-",
date: "-", date: "-",
degree: "-", degree: "-",
}] },
];
const mapData = { const mapData = {
// Id: profile.id, // Id: profile.id,
@ -7874,4 +7878,42 @@ export class ProfileController extends Controller {
]); ]);
return new HttpSuccess(); 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();
}
} }