1
0
forked from PGL/Clyde

link backend Post Patch Delete Lesson

This commit is contained in:
2024-04-16 22:03:48 +02:00
parent 9112004326
commit a2be04bfb3
17 changed files with 282 additions and 79 deletions

View File

@ -8,6 +8,7 @@ import ovh.herisson.Clyde.Tables.Lesson;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.User;
import java.lang.reflect.GenericSignatureFormatError;
import java.util.ArrayList;
import java.util.Map;
@ -38,15 +39,11 @@ public class LessonService {
return toReturn;
}
public boolean modifyData(long id, Map<String ,Object> updates, Role role){
Lesson target = lessonRepo.findById(id);
public Lesson createLesson(Map<String,Object> lessonInfos) {
Lesson target = new Lesson();
if(target == null || role != Role.Secretary)
return false;
for (Map.Entry<String , Object> entry: updates.entrySet()){
switch (entry.getKey()){
for (Map.Entry<String, Object> entry : lessonInfos.entrySet()) {
switch (entry.getKey()) {
case "lessonStart":
target.setLessonStart((String) entry.getValue());
break;
@ -61,6 +58,40 @@ public class LessonService {
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
case "courseId":
target.setCourse(courseRepo.findById((int) entry.getValue()));
}
}
return target;
}
public boolean modifyData(long id, Map<String ,Object> updates){
Lesson target = lessonRepo.findById(id);
System.out.println(target);
if(target == null)
return false;
System.out.println("test");
System.out.println(updates.entrySet());
for (Map.Entry<String , Object> entry: updates.entrySet()){
System.out.println(entry);
switch (entry.getKey()){
case "lessonStart":
target.setLessonStart((String) entry.getValue());
break;
case "lessonEnd":
target.setLessonEnd((String) entry.getValue());
break;
case "local":
target.setLocal((String) entry.getValue());
break;
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
}
}
lessonRepo.save(target);

View File

@ -30,6 +30,14 @@ public class ScheduleLessonService {
return true;
}
public boolean delete(long lessonId){
if(lessonId == 0)
return false;
scheduleLessonRepo.delete(lessonRepo.findById(lessonId));
return true;
}
public Schedule getScheduleByCurriculum(Curriculum curriculum){
return scheduleLessonRepo.findScheduleByCurriculum(curriculum);
}