@Injectable()
export class TCService {
async generateTC(studentId: string, dto: GenerateTCDto) {
const tcNumber = `TC/${year}/${String(count).padStart(5, '0')}`;
const verificationCode = this.generateCode();
const verifyUrl = `https://verify.edupulse.in/tc/${verificationCode}`;
const qrCode = await QRCode.toDataURL(verifyUrl);
const pdf = await this.pdfService.generateTC({
student,
tcNumber,
qrCode,
conduct: dto.conduct,
});
await this.s3.upload({ key: `tc/${tcNumber}.pdf`, body: pdf });
await this.prisma.student.update({
where: { id: studentId },
data: { status: 'TRANSFERRED', tcNumber }
});
return { tcNumber, downloadUrl };
}
async verifyTC(code: string) {
const tc = await this.prisma.transferCertificate.findUnique({
where: { verificationCode: code }
});
return tc ? { isValid: true, ...tc } : { isValid: false };
}
}