feat: menambahkan manajemen akun mentor oleh admin

This commit is contained in:
Muhammad Zhafran Ilham
2026-06-25 22:58:04 +07:00
parent 6a1a3c1a97
commit e8a7521bb0
7 changed files with 881 additions and 3 deletions
@@ -35,6 +35,57 @@ class AdminRepository {
where: { id: parseInt(id) }
});
}
async createMentor(mentorData) {
return prisma.admin.create({
data: {
...mentorData,
role: 'mentor',
},
});
}
async findMentors() {
return prisma.admin.findMany({
where: {
role: 'mentor',
}
});
}
async findMentorById(id) {
return prisma.admin.findFirst({
where: {
id: parseInt(id),
role: 'mentor',
},
});
}
async updateMentorById(id, mentorData) {
return prisma.admin.update({
where: {
id: parseInt(id),
},
data: mentorData,
});
}
async deleteMentorById(id) {
return prisma.admin.delete({
where: {
id: parseInt(id),
},
});
}
async countProjectsByAdminId(idAdmin) {
return prisma.project.count({
where: {
id_admin: parseInt(idAdmin),
},
});
}
}
module.exports = new AdminRepository();