|
|
@ -56,53 +56,11 @@ public class GraduateController { |
|
|
|
var user = TokenTool.getStudentNumber(token); |
|
|
|
var user = TokenTool.getStudentNumber(token); |
|
|
|
var courses = courseTableService.getCourseTable(user); |
|
|
|
var courses = courseTableService.getCourseTable(user); |
|
|
|
LinkedHashSet<Course> filteredCourse = new LinkedHashSet<>(courses); |
|
|
|
LinkedHashSet<Course> filteredCourse = new LinkedHashSet<>(courses); |
|
|
|
var resultList = convertCourseList(filteredCourse); |
|
|
|
var resultList = CourseResponse.convertCourseList(filteredCourse); |
|
|
|
|
|
|
|
|
|
|
|
return Response.success(V2ResponseCode.YJS_GETCOURSE_SUC.getCode(), resultList); |
|
|
|
return Response.success(V2ResponseCode.YJS_GETCOURSE_SUC.getCode(), resultList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 切课,将连着的几节课切开来 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param courses mywust类型的CourseList |
|
|
|
|
|
|
|
* @return List<CourseResponse> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<CourseResponse> convertCourseList(Collection<Course> courses) { |
|
|
|
|
|
|
|
List<CourseResponse> courseResponses = new ArrayList<>(courses.size() * 2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CourseResponse.CourseResponseBuilder builder = CourseResponse.builder(); |
|
|
|
|
|
|
|
for (Course course : courses) { |
|
|
|
|
|
|
|
builder.className(course.getName()); |
|
|
|
|
|
|
|
builder.teachClass(course.getTeachClass()); |
|
|
|
|
|
|
|
builder.classroom(course.getClassroom().getRoom()); |
|
|
|
|
|
|
|
builder.startWeek(course.getStartWeek()); |
|
|
|
|
|
|
|
builder.endWeek(course.getEndWeek()); |
|
|
|
|
|
|
|
builder.weekDay(course.getWeekDay()); |
|
|
|
|
|
|
|
builder.teacher(course.getTeacher()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int startSection = course.getStartSection(); |
|
|
|
|
|
|
|
int endSection = course.getEndSection(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int courseSize = endSection - startSection + 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 课程大小大于2的将课程按两节两节分割,只有一节的按两节处理
|
|
|
|
|
|
|
|
if (courseSize > 2) { |
|
|
|
|
|
|
|
for (int i = 0; i < courseSize / 2; i++) { |
|
|
|
|
|
|
|
int splitStartSection = startSection + i * 2; |
|
|
|
|
|
|
|
int section = splitStartSection - (splitStartSection / 2); |
|
|
|
|
|
|
|
builder.section(section); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
courseResponses.add(builder.build()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
builder.section(startSection - (startSection / 2)); |
|
|
|
|
|
|
|
courseResponses.add(builder.build()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return courseResponses; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/get-grade") |
|
|
|
@RequestMapping("/get-grade") |
|
|
|
public Response<List<GraduateScoreResponse>> getScore(@RequestHeader("Token") String token) { |
|
|
|
public Response<List<GraduateScoreResponse>> getScore(@RequestHeader("Token") String token) { |
|
|
|
var user = TokenTool.getStudentNumber(token); |
|
|
|
var user = TokenTool.getStudentNumber(token); |
|
|
|