Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend #3

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ea0a24
first commit, I've installed key features and settings and created th…
Rudolf31 Nov 23, 2024
9a04467
i`ve finished with profile page
Rudolf31 Nov 24, 2024
94232ae
i've created the page of courses
Rudolf31 Nov 25, 2024
a44c220
test
Rudolf31 Nov 25, 2024
d4e0a67
i've finished with beta-version of courses page
Rudolf31 Nov 25, 2024
2bbb33d
update backend
maxdo1511 Nov 26, 2024
6eec06c
first fetch
Rudolf31 Nov 26, 2024
e24fac2
fix student
maxdo1511 Nov 26, 2024
2f03ad2
fix db and user dto
maxdo1511 Nov 26, 2024
c7a9b46
fix LocalizationService
maxdo1511 Nov 26, 2024
11fbe24
user institutes
maxdo1511 Nov 26, 2024
47a3e2f
Merge branch 'main' into Frontend
ReallyWeirdCat Nov 26, 2024
795c268
fixed curly bracket
ReallyWeirdCat Nov 26, 2024
f115134
i've fixed avatar
Rudolf31 Nov 26, 2024
1b5dfd1
Merge branch 'Frontend' of github.com:EspadaKomanda/IPTIP1CHack into …
Rudolf31 Nov 26, 2024
df3b285
fix
ReallyWeirdCat Nov 26, 2024
b64d581
Merge remote-tracking branch 'refs/remotes/origin/Frontend' into Fron…
ReallyWeirdCat Nov 26, 2024
ec73041
groups
maxdo1511 Nov 26, 2024
9d05081
fix groups
maxdo1511 Nov 26, 2024
865901b
fix courses
maxdo1511 Nov 26, 2024
305de29
study group contoller
maxdo1511 Nov 26, 2024
cbede2e
StudyGroupService missing methods implemented
ReallyWeirdCat Nov 26, 2024
d0f908f
New tasks added, complete tasks removed
ReallyWeirdCat Nov 26, 2024
3de8d9f
ScheduleDto
maxdo1511 Nov 26, 2024
f926d70
Fixed random cringe in the code and made getSchedule method in UserSe…
ReallyWeirdCat Nov 26, 2024
9def025
admin
maxdo1511 Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public ResponseEntity<CourseEntityDto> getCourse(@PathVariable Long id) {
public ResponseEntity<?> attachUserToCourse(@Valid @RequestBody UserCourseModel attachUserToCourseModel) {
courseService.attachUserToCourse(
attachUserToCourseModel.getCourseId(),
attachUserToCourseModel.getUserId()
attachUserToCourseModel.getUserId(),
attachUserToCourseModel.getSemester()
);
return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ public List<CourseLearningResourceCategoryEntityDto> getCourseLearningResourceCa
}

@Transactional
public UserCourseEntity attachUserToCourse(Long courseId, Long userId) {
public UserCourseEntity attachUserToCourse(Long courseId, Long userId, int semester) {
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() -> new RuntimeException("User not found"));
CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow(() -> new RuntimeException("Course not found"));

return userCourseRepository.save(UserCourseEntity.builder()
.courseId(courseEntity.getId())
.userId(userEntity.getId())
.semester(semester)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class UserCourseModel {

private Long courseId;
private Long userId;
private int semester;

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class QuestionEntity {
@Column(nullable = false)
@FieldPermission
private QuestionType questionType;
@Column(nullable = false)
@Column(nullable = false, columnDefinition = "TEXT")
@FieldPermission
private String content;
@ManyToOne
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.NoArgsConstructor;
import ru.espada.ep.iptip.audit.Auditable;
import ru.espada.ep.iptip.study_groups.StudyGroupEntity;
import ru.espada.ep.iptip.user.UserEntity;
import ru.espada.ep.iptip.user.permission.annotation.FieldPermission;
import ru.espada.ep.iptip.user.permission.annotation.Permission;

Expand All @@ -33,14 +34,21 @@ public class EventEntity extends Auditable {
@FieldPermission
private int weekday;
@FieldPermission
private boolean is_week_event;
private Boolean is_week_even;
@FieldPermission
private Long begin_date;
@FieldPermission
private Long end_date;
@Column(nullable = false)
@FieldPermission
private Long duration;
@Column(length = 128)
private String type;
@OneToOne
@JoinColumn(name = "teacher_id")
private UserEntity teacher;
@Column(columnDefinition = "TEXT")
private String location;

@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "study_group_event",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public EventEntity createEvent(Principal principal, CreateEventRequest request)
.name(request.getName())
.date(request.getDate())
.weekday(request.getWeekday())
.is_week_event(request.is_week_event())
.is_week_even(request.is_week_event())
.begin_date(request.getBegin_date())
.end_date(request.getEnd_date())
.duration(request.getDuration())
Expand All @@ -50,7 +50,7 @@ public EventEntity createEventForStudyGroups(Principal principal, CreateEventFor
.name(request.getName())
.date(request.getDate())
.weekday(request.getWeekday())
.is_week_event(request.is_week_event())
.is_week_even(request.is_week_event())
.begin_date(request.getBegin_date())
.end_date(request.getEnd_date())
.duration(request.getDuration())
Expand All @@ -76,7 +76,7 @@ public EventEntity modifyEvent(Principal principal, ModifyEventRequest request)
eventEntity.setDate(Optional.ofNullable(request.getDate()).orElse(eventEntity.getDate()));
// FIXME: i am not sure, can bools be null in java? what will happen down here?
eventEntity.setWeekday(Optional.ofNullable(request.getWeekday()).orElse(eventEntity.getWeekday()));
eventEntity.set_week_event(Optional.ofNullable(request.is_week_event()).orElse(eventEntity.is_week_event()));
eventEntity.setIs_week_even(Optional.ofNullable(request.is_week_event()).orElse(eventEntity.getIs_week_even()));
eventEntity.setBegin_date(Optional.ofNullable(request.getBegin_date()).orElse(eventEntity.getBegin_date()));
eventEntity.setEnd_date(Optional.ofNullable(request.getEnd_date()).orElse(eventEntity.getEnd_date()));
eventEntity.setDuration(Optional.ofNullable(request.getDuration()).orElse(eventEntity.getDuration()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@NoArgsConstructor
@Builder
public class CreateEventForStudyGroupsRequest {
// TODO: implement request model
@NotNull
private String name;
@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public class LocalizationService {

public LocalizationService(@Autowired LocalizationYAMLReader localizationYAMLReader) {
localizedMessages = new HashMap<>();
readAllLocalizationFiles(localizationYAMLReader);
try {
readAllLocalizationFiles(localizationYAMLReader);
}catch (Exception e) {
e.printStackTrace();
}
}

public String getLocalizedMessage(String code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ public PermissionElevator(UserPermissionService userPermissionService) {

@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
if (targetDomainObject.getClass().equals(Long.class)) {
return userPermissionService.hasPermission(authentication.getName(), permission.toString().replace("{" + "long" + "}", targetDomainObject.toString()));
}
String permissionName = permission.toString();
if (targetDomainObject != null) {
if (targetDomainObject.getClass().equals(Long.class)) {
return userPermissionService.hasPermission(authentication.getName(), permission.toString().replace("{" + "long" + "}", targetDomainObject.toString()));
}

for (Field field : targetDomainObject.getClass().getDeclaredFields()) {
field.setAccessible(true);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ru.espada.ep.iptip.study_groups;

import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
Expand All @@ -14,66 +16,63 @@
@RequestMapping("/studyGroup")
public class StudyGroupController {

private StudyGroupRepository studyGroupRepository;
private StudyGroupService studyGroupService;

// TODO: add methods: create, add users, remove users, get users, set semester
@PostMapping("/studyGroup")
public ResponseEntity<?> createStudyGroup(Principal principal, @Valid @RequestBody CreateStudyGroupRequest createStudyGroupRequest) {
// TODO: implementation
return null;
public ResponseEntity<Long> createStudyGroup(Principal principal, @Valid @RequestBody CreateStudyGroupRequest createStudyGroupRequest) {
Long id = studyGroupService.createStudyGroup(principal, createStudyGroupRequest).getId();
return ResponseEntity.ok(id);
}

@PostMapping("/studyGroupWithUsers")
public ResponseEntity<?> createStudyGroupWithUsers(Principal principal, @Valid @RequestBody CreateStudyGroupWithUsersRequest createStudyGroupWithUsersRequest) {
// TODO: implementation
return null;
public ResponseEntity<Long> createStudyGroupWithUsers(Principal principal, @Valid @RequestBody CreateStudyGroupWithUsersRequest createStudyGroupWithUsersRequest) {
Long id = studyGroupService.createStudyGroupWithUsers(principal, createStudyGroupWithUsersRequest).getId();
return ResponseEntity.ok(id);
}

@PatchMapping("/studyGroup")
public ResponseEntity<?> modifyStudyGroup(Principal principal, @Valid @RequestBody ModifyStudyGroupRequest modifyStudyGroupRequest) {
// TODO: implementation
studyGroupService.modifyStudyGroup(principal, modifyStudyGroupRequest);
return null;
}

@DeleteMapping("/studyGroup")
public ResponseEntity<?> deleteStudyGroup(Principal principal, Long studyGroupId) {
// TODO: implementation
return null;
studyGroupService.deleteStudyGroup(principal, studyGroupId);
return ResponseEntity.ok().build();
}

@GetMapping("/studyGroup")
public ResponseEntity<?> getStudyGroup(Principal principal, Long studyGroupId) {
// TODO: implementation
return null;
public ResponseEntity<StudyGroupEntity> getStudyGroup(Principal principal, Long studyGroupId) {
return ResponseEntity.ok().body(studyGroupService.getStudyGroup(principal, studyGroupId));
}

@PostMapping("/attachUser")
public ResponseEntity<?> attachUserToStudyGroup(Principal principal, @Valid @RequestBody AttachUserToStudyGroupRequest attachUserToStudyGroupRequest) {
// TODO: implementation
return null;
public ResponseEntity<?> attachUserToStudyGroup(Principal principal, @Valid @RequestBody AttachUsersToStudyGroupRequest attachUsersToStudyGroupRequest) {
studyGroupService.attachUserToStudyGroup(principal, attachUsersToStudyGroupRequest);
return ResponseEntity.ok().build();
}

@DeleteMapping("/detachUser")
public ResponseEntity<?> detachUserFromStudyGroup(Principal principal, @Valid @RequestBody DetachUserFromStudyGroupRequest detachUserFromStudyGroupRequest) {
// TODO: implementation
return null;
studyGroupService.detachUserFromStudyGroup(principal, detachUserFromStudyGroupRequest);
return ResponseEntity.ok().build();
}

@PutMapping("/setStudyGroupSemester")
public ResponseEntity<?> setStudyGroupSemester(Principal principal, @Valid @RequestBody SetStudyGroupMembersSemesterRequest setStudyGroupMembersSemesterRequest) {
// TODO: implementation
return null;
studyGroupService.setStudyGroupMembersSemester(principal, setStudyGroupMembersSemesterRequest);
return ResponseEntity.ok().build();
}

@GetMapping("/getStudyGroupMembers")
public ResponseEntity<?> getStudyGroupMembers(Principal principal, Long studyGroupId) {
// TODO: implementation
return null;
return ResponseEntity.ok().body(studyGroupService.getStudyGroupMembers(principal, studyGroupId));
}

@Autowired
public void setStudyGroupRepository(StudyGroupRepository studyGroupRepository) {
this.studyGroupRepository = studyGroupRepository;
public void setStudyGroupService(StudyGroupService studyGroupService) {
this.studyGroupService = studyGroupService;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface StudyGroupService {
StudyGroupEntity getStudyGroup(Principal principal, Long studyGroupId);
void deleteStudyGroup(Principal principal, Long studyGroupId);

void attachUserToStudyGroup(Principal principal, AttachUserToStudyGroupRequest request);
void attachUserToStudyGroup(Principal principal, AttachUsersToStudyGroupRequest request);
void detachUserFromStudyGroup(Principal principal, DetachUserFromStudyGroupRequest request);
void setStudyGroupMembersSemester(Principal principal, SetStudyGroupMembersSemesterRequest request);
List<Long> getStudyGroupMembers(Principal principal, Long studyGroupId);
Expand Down
Loading