feat: menambahkan manajemen akun mentor oleh admin
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user