-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTimeTableController.java
More file actions
125 lines (114 loc) · 5.51 KB
/
TimeTableController.java
File metadata and controls
125 lines (114 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package koreatech.in.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import koreatech.in.annotation.ApiOff;
import koreatech.in.annotation.Auth;
import koreatech.in.annotation.AuthExcept;
import koreatech.in.domain.TimeTable.Lecture;
import koreatech.in.domain.TimeTable.Semester;
import koreatech.in.service.TimeTableService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Map;
@Api(tags = "(Normal) TimeTable", description = "시간표")
@Auth(role = Auth.Role.STUDENT)
@Controller
public class TimeTableController {
@Inject
private TimeTableService timeTableService;
@AuthExcept
@RequestMapping(value = "/lectures", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity getLectureList(@ApiParam(value = "학기 (예시:20191)", required = false) @RequestParam(value = "semester_date", defaultValue = "") String semester_date) throws Exception {
return new ResponseEntity<ArrayList<Lecture>>(timeTableService.getLectureList(semester_date), HttpStatus.OK);
}
@AuthExcept
@RequestMapping(value = "/semesters", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity getSemesterList() throws Exception {
return new ResponseEntity<ArrayList<Semester>>(timeTableService.getSemesterList(), HttpStatus.OK);
}
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
@RequestMapping(value = "/timetables", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity getTimetabless(@ApiParam(value = "학기 (예시:20191)", required = true) @RequestParam(value = "semester") String semester) throws Exception {
return new ResponseEntity<Map<String, Object>>(timeTableService.getTimeTables(semester), HttpStatus.OK);
}
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
@RequestMapping(value = "/timetables", method = RequestMethod.POST)
public @ResponseBody
ResponseEntity createTimeTables(@ApiParam(value = "json value (예시:\n" +
"{\n" +
" \"timetable\": [\n" +
" {\n" +
" \"code\": \"CPC490\",\n" +
" \"class_title\": null,\n" +
" \"class_time\": [\n" +
" 210,\n" +
" 211\n" +
" ],\n" +
" \"class_place\": null,\n" +
" \"professor\": null,\n" +
" \"grades\": null,\n" +
" \"lecture_class\": \"01\",\n" +
" \"target\": \"디자 1 건축\",\n" +
" \"regular_number\": \"25\",\n" +
" \"design_score\": \"0\",\n" +
" \"department\": \"디자인ㆍ건축공학부\",\n" +
" \"memo\": null\n" +
" }\n" +
" ],\n" +
" \"semester\": \"20192\"\n" +
"}", required = true) @RequestBody String timetable_log) throws Exception {
return new ResponseEntity<Map<String, Object>>(timeTableService.createTimeTables(timetable_log), HttpStatus.CREATED);
}
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
@RequestMapping(value = "/timetables", method = RequestMethod.PUT)
public @ResponseBody
ResponseEntity updateTimeTable(@ApiParam(value = "json value (예시:\n" +
"{\n" +
" \"timetable\": [\n" +
" {\n" +
" \"id\": 1,\n" +
" \"code\": \"CPC490\",\n" +
" \"class_title\": null,\n" +
" \"class_time\": [\n" +
" 210,\n" +
" 211\n" +
" ],\n" +
" \"class_place\": null,\n" +
" \"professor\": null,\n" +
" \"grades\": null,\n" +
" \"lecture_class\": \"01\",\n" +
" \"target\": \"디자 1 건축\",\n" +
" \"regular_number\": \"25\",\n" +
" \"design_score\": \"0\",\n" +
" \"department\": \"디자인ㆍ건축공학부\",\n" +
" \"memo\": null\n" +
" }\n" +
" ],\n" +
" \"semester\": \"20192\"\n" +
"}", required = true) @RequestBody String timetable_log) throws Exception {
return new ResponseEntity<Map<String, Object>>(timeTableService.updateTimeTable(timetable_log), HttpStatus.CREATED);
}
@ApiOff @ApiIgnore
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
@RequestMapping(value = "/timetables", method = RequestMethod.DELETE)
public @ResponseBody
ResponseEntity deleteTimeTableAll(@ApiParam(value = "학기 (예시:20191)", required = true) @RequestParam(value = "semester") String semester) throws Exception {
return new ResponseEntity<Map<String, Object>>(timeTableService.deleteTimeTableAll(semester), HttpStatus.OK);
}
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
@RequestMapping(value = "/timetable", method = RequestMethod.DELETE)
public @ResponseBody
ResponseEntity deleteTimeTableById(@ApiParam(value = "스케줄의 uid", required = true) @RequestParam(value = "id") int id) throws Exception {
return new ResponseEntity<Map<String, Object>>(timeTableService.deleteTimeTableById(id), HttpStatus.OK);
}
}