Refactor part 1

{{url}}/api/v1/courses/getCourses =>  {{url}}/api/v1/courses/all
{{url}}/api/v1/groups/getCourseGroups?id=13 => {{url}}/api/v1/groups/course/13
{{url}}/api/v1/courses/getCoursesWithGroups => {{url}}/api/v1/courses/all?groups=true
{{url}}/api/v1/commisions/add => {{url}}/api/v1/commisions/user
{{url}}/api/v1/commisions/getAllCommisions => {{url}}/api/v1/commisions/user
{{url}}/api/v1/assignments/getCurrentAssignments =>{{url}}/api/v1/assignments/user
{{url}}/api/v1/users/searchForStudents => {{url}}/api/v1/users/search

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-10-30 16:42:57 +01:00
parent 4267fadf62
commit 2b59c181e5
6 changed files with 20 additions and 20 deletions

View File

@ -32,7 +32,7 @@ public class AssignmentsController extends TokenBasedController {
@Autowired
private AssignmentService assignmentService;
@GetMapping("/getCurrentAssignments")
@GetMapping("/user")
public ResponseEntity<List<GetCurrentAssignmentsResponse>> getCurrentAssignments() throws Exception {
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
Optional<Commision> com = this.commisionService.getNewestCommision(user);

View File

@ -42,7 +42,7 @@ public class CommisionController extends TokenBasedController {
public CommisionController() {
}
@PostMapping("/add")
@PostMapping("/user")
public ResponseEntity<String> addCommision(@RequestBody List<Long> groups) throws UserNotFoundException {
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException());
@ -58,7 +58,7 @@ public class CommisionController extends TokenBasedController {
return new ResponseEntity<>("Succes", HttpStatus.OK);
}
@GetMapping("/getAllCommisions")
@GetMapping("/user")
public ResponseEntity<List<CommisionResponse>> getAlCommisions() throws UserNotFoundException {
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException());
List<CommisionResponse> result = CommisionResponseMappers

View File

@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.plannaplan.responses.models.abstracts.CoursesResponse;
@RestController
@CrossOrigin
@ -24,20 +26,15 @@ public class CoursesController {
@Autowired
private CourseService courseService;
@GetMapping("/getCourses")
public ResponseEntity<List<GetCoursesResponse>> getMethodName() {
@GetMapping("/all")
public ResponseEntity<List<? extends CoursesResponse>> getMethodName(@RequestParam(name = "groups", defaultValue = "false") Boolean groups) {
List<Course> courses = this.courseService.getAllCourses();
List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
return new ResponseEntity<>(response, HttpStatus.OK);
}
@GetMapping("/getCoursesWithGroups")
public ResponseEntity<List<GetCoursesWithGroupsResponse>> getCoursesWithGroups() {
final List<Course> courses = this.courseService.getAllCourses();
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
if (groups) {
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
.mapToGetCoursesWithGroupsResponse(courses);
return new ResponseEntity<>(response, HttpStatus.OK);
}
final List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}

View File

@ -14,19 +14,22 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/groups")
public class GroupController {
@Autowired
private GroupService groupService;
@GetMapping("/getCourseGroups")
public ResponseEntity<GetCourseGroupsResponse<? extends DefaultGroupResponse>> getCourses(@RequestParam("id") Long id,
@GetMapping("/course/{id}")
public ResponseEntity<GetCourseGroupsResponse<? extends DefaultGroupResponse>> getCourses(@PathVariable(name = "id") Long id,
@RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) {
List<Groups> groups = this.groupService.getGroupsByCourse(id);
if (capacity) {

View File

@ -27,7 +27,7 @@ public class UsersController {
@Autowired
private UserService userService;
@GetMapping("/searchForStudents")
@GetMapping("/search")
@PreAuthorize("hasRole('ROLE_DEANERY')")
public ResponseEntity<List<SearchForStudentsResponse>> configApp(@RequestParam("query") String query) {

View File

@ -36,8 +36,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(final WebSecurity webSecurity) {
webSecurity.ignoring().antMatchers("/token**").antMatchers("/api/v1/courses/getCourses")
.antMatchers("/api/v1/groups/getCourseGroups").antMatchers("/api/v1/courses/getCoursesWithGroups");
webSecurity.ignoring().antMatchers("/token**").antMatchers("/api/v1/courses/all")
.antMatchers("/api/v1/groups/course/{id}");
}
@Override