Skip to content

Commit a569812

Browse files
authored
Merge pull request #12 from BCSDLab/release/1.2.0
Release/1.2.0
2 parents e83f410 + 964cd30 commit a569812

10 files changed

Lines changed: 127 additions & 6 deletions

File tree

src/main/java/koreatech/in/controller/CalendarController.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ public class CalendarController {
2121

2222
@RequestMapping(value = "/calendars", method = RequestMethod.GET)
2323
public @ResponseBody
24-
ResponseEntity getCalendars(@ApiParam(required = true) @RequestParam(value = "year") String year) {
25-
return new ResponseEntity<List<Calendar>>(calendarService.getCalendars(year), HttpStatus.OK);
24+
ResponseEntity<List<Calendar>> getCalendars(@ApiParam(required = true) @RequestParam(value = "year") String year) {
25+
return new ResponseEntity<>(calendarService.getCalendars(year), HttpStatus.OK);
26+
}
27+
28+
@RequestMapping(value = "/term", method = RequestMethod.GET)
29+
public @ResponseBody
30+
ResponseEntity<String> getTerm() throws Exception {
31+
return new ResponseEntity<>(calendarService.getTerm(), HttpStatus.OK);
2632
}
2733
}

src/main/java/koreatech/in/controller/TimeTableController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import koreatech.in.annotation.Auth;
77
import koreatech.in.annotation.AuthExcept;
88
import koreatech.in.domain.TimeTable.Lecture;
9+
import koreatech.in.domain.TimeTable.Semester;
910
import koreatech.in.service.TimeTableService;
1011
import org.springframework.http.HttpStatus;
1112
import org.springframework.http.ResponseEntity;
1213
import org.springframework.stereotype.Controller;
1314
import org.springframework.web.bind.annotation.*;
1415

1516
import javax.inject.Inject;
17+
import java.security.MessageDigest;
1618
import java.util.ArrayList;
1719
import java.util.Map;
1820

@@ -30,6 +32,13 @@ ResponseEntity getLectureList(@ApiParam(value = "학기 (예시:20191)", require
3032
return new ResponseEntity<ArrayList<Lecture>>(timeTableService.getLectureList(semester_date), HttpStatus.OK);
3133
}
3234

35+
@AuthExcept
36+
@RequestMapping(value = "/semesters", method = RequestMethod.GET)
37+
public @ResponseBody
38+
ResponseEntity getSemesterList() throws Exception {
39+
return new ResponseEntity<ArrayList<Semester>>(timeTableService.getSemesterList(), HttpStatus.OK);
40+
}
41+
3342
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
3443
@RequestMapping(value = "/timetables", method = RequestMethod.GET)
3544
public @ResponseBody
@@ -66,4 +75,6 @@ ResponseEntity deleteTimeTableAll(@ApiParam(value = "학기 (예시:20191)", req
6675
ResponseEntity deleteTimeTableById(@ApiParam(value = "스케줄의 uid", required = true) @RequestParam(value = "id") int id) throws Exception {
6776
return new ResponseEntity<Map<String, Object>>(timeTableService.deleteTimeTableById(id), HttpStatus.OK);
6877
}
78+
79+
6980
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package koreatech.in.controller.admin;
2+
3+
import io.swagger.annotations.ApiOperation;
4+
import io.swagger.annotations.ApiParam;
5+
import io.swagger.annotations.Authorization;
6+
import koreatech.in.annotation.Auth;
7+
import koreatech.in.service.CalendarService;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.stereotype.Controller;
11+
import org.springframework.web.bind.annotation.RequestBody;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestMethod;
14+
import org.springframework.web.bind.annotation.ResponseBody;
15+
16+
import javax.inject.Inject;
17+
18+
@Auth(role = Auth.Role.ADMIN, authority = Auth.Authority.COMMUNITY)
19+
@Controller
20+
public class AdminCalendarController {
21+
@Inject
22+
private CalendarService calendarService;
23+
24+
@ApiOperation(value = "", authorizations = {@Authorization(value="Authorization")})
25+
@RequestMapping(value = "/admin/term", method = RequestMethod.POST)
26+
public @ResponseBody
27+
ResponseEntity<String> createTerm(@ApiParam(required = true, value = "10: 1학기 정규, 11: 1학기 계절, 20: 2학기 정규, 21: 2학기 계절") @RequestBody String term) {
28+
29+
return new ResponseEntity<>(calendarService.createTermForAdmin(term), HttpStatus.CREATED);
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package koreatech.in.domain.TimeTable;
2+
3+
import io.swagger.annotations.ApiModelProperty;
4+
5+
import java.util.Arrays;
6+
import java.util.regex.Pattern;
7+
8+
public class Semester {
9+
@ApiModelProperty(notes = "id", example = "1")
10+
private Integer id;
11+
12+
@ApiModelProperty(notes = "학기", example = "20192")
13+
private String semester;
14+
15+
public Integer getId() {
16+
return id;
17+
}
18+
19+
public String getSemester() {
20+
return semester;
21+
}
22+
23+
public void setId(Integer id) {
24+
this.id = id;
25+
}
26+
27+
public void setSemester(String semester) {
28+
this.semester = semester;
29+
}
30+
}

src/main/java/koreatech/in/domain/User/User.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class User implements UserDetails {
3131
protected String student_number;
3232
@ApiModelProperty(notes = "기계공학부, 컴퓨터공학부, 메카트로닉스공학부, 전기전자통신공학부, 디자인건축공학부, 에너지신소재화학공학부, 산업경영학부", example = "컴퓨터공학부")
3333
protected String major;
34-
@NotNull(groups = {ValidationGroups.CreateAdmin.class}, message = "신원은 비워둘 수 없습니다.")
3534
@ApiModelProperty(notes = "신원(0: 학생, 1: 대학원생, 2: 교수, 3: 교직원, 4: 졸업생, 5: 점주)", example = "0")
3635
protected Integer identity;
3736
@ApiModelProperty(notes = "졸업 여부", example = "false")

src/main/java/koreatech/in/repository/TimeTableMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package koreatech.in.repository;
22

33
import koreatech.in.domain.TimeTable.Lecture;
4+
import koreatech.in.domain.TimeTable.Semester;
45
import koreatech.in.domain.TimeTable.TimeTable;
56
import org.apache.ibatis.annotations.*;
67
import org.springframework.stereotype.Repository;
78

89
import java.util.ArrayList;
10+
import java.util.Map;
911

1012
@Repository("timeTableMapper")
1113
public interface TimeTableMapper {
@@ -48,4 +50,7 @@ public interface TimeTableMapper {
4850

4951
@Select("SELECT id FROM koin.semester WHERE semester = #{semester}")
5052
Integer getSemesterId(@Param("semester") String semester);
53+
54+
@Select("SELECT * FROM koin.semester order by semester desc limit 10")
55+
ArrayList<Semester> getSemesterList();
5156
}

src/main/java/koreatech/in/service/CalendarService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
import java.util.List;
77

88
public interface CalendarService {
9-
public List<Calendar> getCalendars(String year);
9+
List<Calendar> getCalendars(String year);
10+
11+
String getTerm() throws Exception;
12+
13+
String createTermForAdmin(String term);
1014
}

src/main/java/koreatech/in/service/CalendarServiceImpl.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,46 @@
22

33
import koreatech.in.domain.ErrorMessage;
44
import koreatech.in.domain.kut.Calendar;
5+
import koreatech.in.exception.NotFoundException;
56
import koreatech.in.exception.PreconditionFailedException;
67
import koreatech.in.repository.CalendarMapper;
8+
import org.springframework.data.redis.core.ValueOperations;
79
import org.springframework.stereotype.Service;
810

11+
import javax.annotation.Resource;
912
import javax.inject.Inject;
1013
import java.util.List;
1114

1215
@Service
13-
public class CalendarServiceImpl implements CalendarService{
16+
public class CalendarServiceImpl implements CalendarService {
1417
@Inject
1518
CalendarMapper calendarMapper;
1619

20+
@Resource(name = "redisTemplate")
21+
private ValueOperations<String, String> valueOps;
22+
1723
@Override
1824
public List<Calendar> getCalendars(String year) {
19-
if(year == null) {
25+
if (year == null) {
2026
throw new PreconditionFailedException(new ErrorMessage("year is required", 0));
2127
}
2228
return calendarMapper.getCalendarsByYear(year);
2329
}
30+
31+
@Override
32+
public String getTerm() throws Exception {
33+
String term = valueOps.get("termCode");
34+
35+
// 데이터 존재여부 확인
36+
if(term == null) {
37+
throw new NotFoundException(new ErrorMessage("저장된 학기 코드가 없습니다.", 0));
38+
}
39+
return term;
40+
}
41+
42+
@Override
43+
public String createTermForAdmin(String term) {
44+
valueOps.set("termCode", term);
45+
return term;
46+
}
2447
}

src/main/java/koreatech/in/service/TimeTableService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package koreatech.in.service;
22

33
import koreatech.in.domain.TimeTable.Lecture;
4+
import koreatech.in.domain.TimeTable.Semester;
45
import koreatech.in.domain.TimeTable.TimeTable;
56

67
import java.util.ArrayList;
@@ -9,6 +10,8 @@
910
public interface TimeTableService {
1011
ArrayList<Lecture> getLectureList(String semester_date) throws Exception;
1112

13+
ArrayList<Semester> getSemesterList() throws Exception;
14+
1215
Map<String, Object> getTimeTables(String semester) throws Exception;
1316

1417
Map<String, Object> createTimeTables(String timetable_log) throws Exception;
@@ -18,4 +21,5 @@ public interface TimeTableService {
1821
Map<String, Object> deleteTimeTableAll(String semester) throws Exception;
1922

2023
Map<String, Object> deleteTimeTableById(int id) throws Exception;
24+
2125
}

src/main/java/koreatech/in/service/TimeTableServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import koreatech.in.domain.ErrorMessage;
66
import koreatech.in.domain.TimeTable.Lecture;
7+
import koreatech.in.domain.TimeTable.Semester;
78
import koreatech.in.domain.TimeTable.TimeTable;
89
import koreatech.in.domain.User.User;
910
import koreatech.in.exception.*;
@@ -35,6 +36,11 @@ public ArrayList<Lecture> getLectureList(String semester_date) throws Exception
3536
return timeTableMapper.getLectureList(semester_date);
3637
}
3738

39+
@Override
40+
public ArrayList<Semester> getSemesterList() throws Exception {
41+
return timeTableMapper.getSemesterList();
42+
}
43+
3844
@Override
3945
public Map<String, Object> getTimeTables(String semester) throws Exception {
4046
User user = jwtValidator.validate();
@@ -224,4 +230,6 @@ public Map<String, Object> deleteTimeTableById(int id) throws Exception {
224230
put("success", true);
225231
}};
226232
}
233+
234+
227235
}

0 commit comments

Comments
 (0)