Added controllers description

This commit is contained in:
BuildTools 2020-11-04 16:40:02 +01:00
parent ba26d67cd4
commit b308373062
8 changed files with 35 additions and 6 deletions

View File

@ -30,8 +30,8 @@ public class Swagger2Config extends WebMvcConfigurationSupport {
} }
private ApiInfo apiInfo() { private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("xxxxx").description("Swagger2 builds RESTful APIs") return new ApiInfoBuilder().title("plannaplan").description("Aplikacja do zapisów na zajęcia UAM.")
.termsOfServiceUrl("http://www.baidu.com/") .termsOfServiceUrl("https://plannaplan.pl/")
// .contact("") // .contact("")
.version("1.0").build(); .version("1.0").build();
} }

View File

@ -4,6 +4,8 @@ import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -24,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/assignments") @RequestMapping("/api/" + App.API_VERSION + "/assignments")
@Api(tags = {
"Assignments" }, value = "Assignments", description = "Assignment is representation of student willing to join given group (lecture or calss)")
public class AssignmentsController extends TokenBasedController { public class AssignmentsController extends TokenBasedController {
@Autowired @Autowired

View File

@ -4,6 +4,8 @@ import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import java.util.List; import java.util.List;
import com.plannaplan.App; import com.plannaplan.App;
@ -28,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/commisions") @RequestMapping("/api/" + App.API_VERSION + "/commisions")
@Api(tags = {
"Commisions" }, value = "Commisions", description = "Commision is representation of student selected assignments at time. All assignments are attached to some commision so we can see current assignments and also browse histroy of changes for given user")
public class CommisionController extends TokenBasedController { public class CommisionController extends TokenBasedController {
@Autowired @Autowired

View File

@ -19,10 +19,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import io.swagger.annotations.Api;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/configurator") @RequestMapping("/api/" + App.API_VERSION + "/configurator")
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@Api(tags = { "ConfigController" }, value = "ConfigController", description = "All endpoints to configure an app")
public class ConfigController { public class ConfigController {
@Autowired @Autowired

View File

@ -14,6 +14,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -22,16 +25,19 @@ import com.plannaplan.responses.models.abstracts.CoursesResponse;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/courses") @RequestMapping("/api/" + App.API_VERSION + "/courses")
@Api(tags = {
"Course" }, value = "Course", description = "Endpoints to deal with courses. All courses can have classes, lectures or both.")
public class CoursesController { public class CoursesController {
@Autowired @Autowired
private CourseService courseService; private CourseService courseService;
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<List<? extends CoursesResponse>> getMethodName(@RequestParam(name = "groups", defaultValue = "false") Boolean groups) { public ResponseEntity<List<? extends CoursesResponse>> getMethodName(
@RequestParam(name = "groups", defaultValue = "false") Boolean groups) {
List<Course> courses = this.courseService.getAllCourses(); List<Course> courses = this.courseService.getAllCourses();
if (groups) { if (groups) {
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
.mapToGetCoursesWithGroupsResponse(courses); .mapToGetCoursesWithGroupsResponse(courses);
return new ResponseEntity<>(response, HttpStatus.OK); return new ResponseEntity<>(response, HttpStatus.OK);
} }
final List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses); final List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);

View File

@ -19,17 +19,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/groups") @RequestMapping("/api/" + App.API_VERSION + "/groups")
@Api(tags = {
"Group" }, value = "Group", description = "Enpoints to deal with gorups. Group is related directly to course and can be either class and lecture")
public class GroupController { public class GroupController {
@Autowired @Autowired
private GroupService groupService; private GroupService groupService;
@GetMapping("/course/{id}") @GetMapping("/course/{id}")
public ResponseEntity<GetCourseGroupsResponse<? extends DefaultGroupResponse>> getCourses(@PathVariable(name = "id") Long id, public ResponseEntity<GetCourseGroupsResponse<? extends DefaultGroupResponse>> getCourses(
@PathVariable(name = "id") Long id,
@RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) { @RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) {
List<Groups> groups = this.groupService.getGroupsByCourse(id); List<Groups> groups = this.groupService.getGroupsByCourse(id);
if (capacity) { if (capacity) {

View File

@ -13,8 +13,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
@RestController @RestController
@CrossOrigin @CrossOrigin
@Api(tags = { "Token" }, value = "Token", description = "Enpoints to get authorization.")
public class TokenController { public class TokenController {
private final static String SERVICE_URL = "http://localhost:3000"; private final static String SERVICE_URL = "http://localhost:3000";

View File

@ -15,6 +15,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@CrossOrigin @CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/users") @RequestMapping("/api/" + App.API_VERSION + "/users")
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@Api(tags = { "Users" }, value = "Users", description = "Endpoints to deal with users.")
public class UsersController { public class UsersController {
@Autowired @Autowired
private UserService userService; private UserService userService;