|
@@ -31,7 +31,6 @@ import com.qxgmat.service.extend.*;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.MediaType;
|
|
@@ -41,7 +40,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
-import javax.tools.Tool;
|
|
|
import javax.validation.Validator;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
@@ -143,6 +141,9 @@ public class MyController {
|
|
|
private UserCourseAppointmentService userCourseAppointmentService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private UserCourseAppointmentCommentService userCourseAppointmentCommentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private UserCourseProgressService userCourseProgressService;
|
|
|
|
|
|
@Autowired
|
|
@@ -1595,10 +1596,10 @@ public class MyController {
|
|
|
Page<UserOrderRecord> p;
|
|
|
if (module == CourseModule.ONLINE){
|
|
|
// 在线课程包含:视频课程、小班课程
|
|
|
- p = userOrderRecordService.listWithCourse(page, size, user.getId(), new String[]{CourseModule.VIDEO.key, CourseModule.ONLINE.key}, null,null, order, DirectionStatus.ValueOf(direction));
|
|
|
+ p = userOrderRecordService.listWithCourse(page, size, user.getId(), new String[]{CourseModule.VIDEO.key}, isUsed,isEnd, order, DirectionStatus.ValueOf(direction));
|
|
|
} else if (module == CourseModule.VS){
|
|
|
// 1v1课程:只有系统授课有作业
|
|
|
- p = userOrderRecordService.listWithCourse(page, size, user.getId(), new String[]{CourseModule.VS.key}, null,null, order, DirectionStatus.ValueOf(direction));
|
|
|
+ p = userOrderRecordService.listWithCourse(page, size, user.getId(), new String[]{CourseModule.VS.key}, isUsed,isEnd, order, DirectionStatus.ValueOf(direction));
|
|
|
}else{
|
|
|
throw new ParameterException("课程类型错误");
|
|
|
}
|
|
@@ -1615,34 +1616,22 @@ public class MyController {
|
|
|
List<Course> courseList = courseService.select(courseIds);
|
|
|
Map courseMap = Transform.getMap(courseList, Course.class, "id");
|
|
|
Transform.combine(pr, courseList, UserCourseDetailDto.class, "productId", "course", Course.class, "id", CourseExtendDto.class);
|
|
|
- for(UserCourseDetailDto dto : pr){
|
|
|
- Course course = (Course)courseMap.get(dto.getProductId());
|
|
|
- CourseExtendDto courseExtendDto = dto.getCourse();
|
|
|
- if (course.getCourseModule().equals(CourseModule.VS.key)){
|
|
|
- // 根据课时数进行计算
|
|
|
- courseExtendDto.setExpireDays(courseExtendService.computeExpire(dto.getNumber(), course));
|
|
|
- }else if(course.getCourseModule().equals(CourseModule.VIDEO.key)){
|
|
|
- // 根据设置进行计算
|
|
|
- courseExtendDto.setExpireDays(courseExtendService.computeExpire(course));
|
|
|
- }else if(course.getCourseModule().equals(CourseModule.ONLINE.key)){
|
|
|
- // 根据使用时长计算
|
|
|
- courseExtendDto.setExpireDays((int)(dto.getUseEndTime().getTime() - dto.getUseStartTime().getTime() / 86400000));
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
// 绑定课时、预约、进度
|
|
|
Map<Object, Collection<CourseNo>> courseNoMap = courseNoService.groupByCourseId(courseIds);
|
|
|
Transform.combine(pr, courseNoMap, UserCourseDetailDto.class, "productId", "courseNos", CourseNoExtendDto.class);
|
|
|
|
|
|
Map<Object, Collection<UserCourseAppointment>> appointmentMap = userCourseAppointmentService.groupByRecordId(recordIds);
|
|
|
- Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "productId", "appointments", UserCourseAppointmentExtendDto.class);
|
|
|
+ Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "id", "appointments", UserCourseAppointmentExtendDto.class);
|
|
|
|
|
|
Map<Object, Collection<UserCourseProgress>> progressMap = userCourseProgressService.groupByRecordId(recordIds);
|
|
|
+ Transform.combine(pr, progressMap, UserCourseDetailDto.class, "id", "progress", UserCourseProgressExtendDto.class);
|
|
|
Map<Object, Collection<UserCourseRecord>> recordMap = userCourseRecordService.groupByRecordId(recordIds);
|
|
|
for(UserCourseDetailDto dto : pr){
|
|
|
+ Collection<CourseNo> courseNos = courseNoMap.get(dto.getProductId());
|
|
|
+ if (courseNos == null || courseNos.size() == 0) continue;
|
|
|
Collection<UserCourseProgress> list = progressMap.get(dto.getId());
|
|
|
if (list == null || list.size() == 0) continue;
|
|
|
- Collection<CourseNo> courseNos = courseNoMap.get(dto.getProductId());
|
|
|
dto.setCurrentNo(courseExtendService.computeCourseNoCurrent(courseNos, list));
|
|
|
Collection<UserCourseRecord> userCourseRecords = recordMap.get(dto.getId());
|
|
|
dto.setTotalTime(courseExtendService.computeCourseTime(userCourseRecords));
|
|
@@ -1650,8 +1639,8 @@ public class MyController {
|
|
|
}
|
|
|
|
|
|
// 获取每个科目的所有作业
|
|
|
- Map<Object, Collection<UserPreviewPaperRelation>> previewMap = previewService.groupByCourseId(user.getId(), recordIds, 1000);
|
|
|
- Transform.combine(pr, previewMap, UserCourseDetailDto.class, "productId", "papers", BasePaperExtendDto.class);
|
|
|
+ Map<Object, Collection<UserPreviewPaperRelation>> previewMap = previewService.groupByRecordId(user.getId(), recordIds, 1000);
|
|
|
+ Transform.combine(pr, previewMap, UserCourseDetailDto.class, "id", "papers", BasePaperExtendDto.class);
|
|
|
for(UserCourseDetailDto dto : pr){
|
|
|
Collection<UserPreviewPaperRelation> list = previewMap.get(dto.getId());
|
|
|
if (list == null || list.size() == 0) continue;
|
|
@@ -1673,10 +1662,7 @@ public class MyController {
|
|
|
|
|
|
// 提问数、笔记数
|
|
|
Map<Object, Collection<UserAskCourse>> askMap = userAskCourseService.groupByRecordId(recordIds);
|
|
|
- Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "productId", "appointments", UserCourseAppointmentExtendDto.class);
|
|
|
-
|
|
|
Map<Object, Collection<UserNoteCourse>> noteMap = userNoteCourseService.groupByCourse(courseIds);
|
|
|
- Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "productId", "notes", UserNoteCourseExtendDto.class);
|
|
|
for(UserCourseDetailDto dto : pr){
|
|
|
Collection<CourseNoExtendDto> courseNos = dto.getCourseNos();
|
|
|
if (courseNos == null) continue;
|
|
@@ -1685,6 +1671,83 @@ public class MyController {
|
|
|
Collection<UserNoteCourse> noteList = noteMap.get(dto.getProductId());
|
|
|
Map notes = Transform.getMap(noteList, UserNoteCourse.class, "courseNoId");
|
|
|
int noteNumber = 0;
|
|
|
+ int askNumber = askList == null ? 0: askList.size();
|
|
|
+ int answerNumber = askList == null ? 0 : (int)askList.stream().filter(r->r.getAnswerStatus()==AskStatus.ANSWER.index).count();
|
|
|
+ for(CourseNoExtendDto courseNo : courseNos){
|
|
|
+ if (notes.get(courseNo.getId()) != null){
|
|
|
+ courseNo.setNote(true);
|
|
|
+ noteNumber += 1;
|
|
|
+ }
|
|
|
+ List<UserAskCourse> askListNo = askListMap.get(courseNo.getId());
|
|
|
+ if (askListNo != null){
|
|
|
+ courseNo.setAskNumber(askListNo.size());
|
|
|
+ courseNo.setAnswerNumber((int)askListNo.stream().filter(r->r.getAnswerStatus()==AskStatus.ANSWER.index).count());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setNoteNumber(noteNumber);
|
|
|
+ dto.setAskNumber(askNumber);
|
|
|
+ dto.setAnswerNumber(answerNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ // vs预约comment
|
|
|
+ Map<Object, Collection<UserCourseAppointmentComment>> commentMap = userCourseAppointmentCommentService.groupByRecordId(recordIds);
|
|
|
+ Transform.combine(pr, commentMap, UserCourseDetailDto.class, "id", "comments", UserCourseAppointmentComment.class);
|
|
|
+
|
|
|
+
|
|
|
+ return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/detail", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "购买的课程记录", httpMethod = "GET")
|
|
|
+ public Response<UserCourseDetailDto> detailCourse(int recordId,
|
|
|
+ HttpSession session) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ UserOrderRecord record = userOrderRecordService.get(recordId);
|
|
|
+ UserCourseDetailDto dto = Transform.convert(record, UserCourseDetailDto.class);
|
|
|
+
|
|
|
+ // 绑定课程
|
|
|
+ Course course = courseService.get(record.getProductId());
|
|
|
+ dto.setCourse(Transform.convert(course, CourseExtendDto.class));
|
|
|
+
|
|
|
+ // 绑定课时、预约、进度
|
|
|
+ List<CourseNo> courseNoList = courseNoService.allCourse(course.getId());
|
|
|
+ dto.setCourseNos(Transform.convert(courseNoList, CourseNoExtendDto.class));
|
|
|
+
|
|
|
+ List<UserCourseAppointment> appointmentList = userCourseAppointmentService.listByRecord(recordId);
|
|
|
+ dto.setAppointments(Transform.convert(appointmentList, UserCourseAppointmentExtendDto.class));
|
|
|
+
|
|
|
+ List<UserCourseProgress> progressList = userCourseProgressService.listCourse(recordId, course.getId());
|
|
|
+ List<UserCourseRecord> recordList = userCourseRecordService.allWithRecord(recordId);
|
|
|
+ if(progressList != null)dto.setCurrentNo(courseExtendService.computeCourseNoCurrent(courseNoList, progressList));
|
|
|
+ if(recordList != null)dto.setTotalTime(courseExtendService.computeCourseTime(recordList));
|
|
|
+ if(recordList != null)dto.setTotalDays(courseExtendService.computeCourseDay(record, recordList));
|
|
|
+
|
|
|
+ // 获取每个科目的所有作业
|
|
|
+ List<UserPreviewPaperRelation> previewList = previewService.list(1, 1000, recordId, user.getId(), null,null);
|
|
|
+ dto.setPapers(Transform.convert(previewList, BasePaperExtendDto.class));
|
|
|
+ int finish = 0;
|
|
|
+ for(UserPreviewPaperRelation relation : previewList){
|
|
|
+ if (relation.getPaper() == null) continue;
|
|
|
+ UserPaper paper = relation.getPaper();
|
|
|
+ if (paper.getTimes() > 0){
|
|
|
+ finish += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setPreviewProgress(finish * 100 / previewList.size());
|
|
|
+
|
|
|
+ // 绑定老师
|
|
|
+ CourseTeacher teacher = courseTeacherService.get(record.getTeacherId());
|
|
|
+ dto.setTeacher(Transform.convert(teacher, CourseTeacherExtendDto.class));
|
|
|
+
|
|
|
+ // 提问数、笔记数
|
|
|
+ Collection<CourseNoExtendDto> courseNos = dto.getCourseNos();
|
|
|
+ if (courseNos != null && courseNos.size() > 0) {
|
|
|
+ Collection<UserAskCourse> askList = userAskCourseService.listByRecord(recordId);
|
|
|
+ Map<Object, List<UserAskCourse>> askListMap = Transform.getMapList(askList, UserAskCourse.class, "courseNoId");
|
|
|
+ Collection<UserNoteCourse> noteList = userNoteCourseService.listByCourse(course.getId());
|
|
|
+ Map notes = Transform.getMap(noteList, UserNoteCourse.class, "courseNoId");
|
|
|
+ int noteNumber = 0;
|
|
|
int askNumber = askList.size();
|
|
|
int answerNumber = (int)askList.stream().filter(r->r.getAnswerStatus()==AskStatus.ANSWER.index).count();
|
|
|
for(CourseNoExtendDto courseNo : courseNos){
|
|
@@ -1703,8 +1766,76 @@ public class MyController {
|
|
|
dto.setAnswerNumber(answerNumber);
|
|
|
}
|
|
|
|
|
|
+ // vs预约comment
|
|
|
+ List<UserCourseAppointmentComment> commentList = userCourseAppointmentCommentService.listByRecord(recordId);
|
|
|
+ dto.setComments(commentList);
|
|
|
|
|
|
- return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/cctalk_name", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "设置课程cctalk", notes = "设置课程cctalk", httpMethod = "POST")
|
|
|
+ public Response<Boolean> setCourseCCTalkName(@RequestBody @Validated UserCourseCCTalkNameDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserOrderRecord entity = Transform.dtoToEntity(dto);
|
|
|
+ UserOrderRecord in = userOrderRecordService.get(dto.getId());
|
|
|
+ if (!in.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+ entity = userOrderRecordService.edit(entity);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/appointment/question", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "预约提交答疑文档", notes = "预约提交答疑文档", httpMethod = "POST")
|
|
|
+ public Response<Boolean> uploadAppointmentQuestion(@RequestBody @Validated UserCourseAppointmentQuestionDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserCourseAppointment entity = Transform.dtoToEntity(dto);
|
|
|
+ UserCourseAppointment in = userCourseAppointmentService.get(dto.getId());
|
|
|
+ if (!in.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+ entity = userCourseAppointmentService.edit(entity);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/appointment/comment/add", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "预约评论添加", notes = "预约评论添加", httpMethod = "POST")
|
|
|
+ public Response<Boolean> addAppointmentComment(@RequestBody @Validated UserCourseAppointmentCommentDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserCourseAppointmentComment entity = Transform.dtoToEntity(dto);
|
|
|
+ UserCourseAppointment appointment = userCourseAppointmentService.get(entity.getAppointmentId());
|
|
|
+ entity.setUserId(user.getId());
|
|
|
+ entity.setRecordId(appointment.getRecordId());
|
|
|
+ entity = userCourseAppointmentCommentService.add(entity);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/appointment/comment/edit", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "预约评论编辑", notes = "预约评论编辑", httpMethod = "POST")
|
|
|
+ public Response<Boolean> editAppointmentComment(@RequestBody @Validated UserCourseAppointmentCommentDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserCourseAppointmentComment entity = Transform.dtoToEntity(dto);
|
|
|
+
|
|
|
+ UserCourseAppointmentComment in = userCourseAppointmentCommentService.get(dto.getId());
|
|
|
+ if (!in.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+ entity = userCourseAppointmentCommentService.edit(entity);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/appointment/comment/delete", method = RequestMethod.DELETE)
|
|
|
+ @ApiOperation(value = "预约评论删除", notes = "预约评论删除", httpMethod = "DELETE")
|
|
|
+ public Response<Boolean> deleteAppointmentComment(int id) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ UserCourseAppointmentComment in = userCourseAppointmentCommentService.get(id);
|
|
|
+ if (!in.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+ userCourseAppointmentCommentService.delete(id);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/course/suspend", method = RequestMethod.POST)
|
|
@@ -1729,11 +1860,11 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/course/time", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "时间表", notes = "时间表", httpMethod = "GET")
|
|
|
- public Response<List<UserCourseTimeDto>> timeCourse(int id) {
|
|
|
+ public Response<List<UserCourseTimeDto>> timeCourse(int recordId) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
List<UserCourseTimeDto> dtos = new ArrayList<>();
|
|
|
|
|
|
- UserOrderRecord record = userOrderRecordService.get(id);
|
|
|
+ UserOrderRecord record = userOrderRecordService.get(recordId);
|
|
|
if (record == null){
|
|
|
throw new ParameterException("记录不存在");
|
|
|
}
|
|
@@ -1759,7 +1890,7 @@ public class MyController {
|
|
|
List<Long> tmpList = new ArrayList<>();
|
|
|
|
|
|
// 获取听课记录
|
|
|
- List<UserCourseRecord> userCourseRecordList = userCourseRecordService.allWithRecord(id);
|
|
|
+ List<UserCourseRecord> userCourseRecordList = userCourseRecordService.allWithRecord(recordId);
|
|
|
tmpList.clear();
|
|
|
for(UserCourseRecord userCourseRecord:userCourseRecordList){
|
|
|
Date day = Tools.day(userCourseRecord.getCreateTime());
|
|
@@ -1778,7 +1909,7 @@ public class MyController {
|
|
|
Collection courseNoIds = Transform.getIds(courseNoList, CourseNo.class, "id");
|
|
|
List<PreviewAssign> previewAssignList = previewAssignService.listByCourseNos(courseId, courseNoIds);
|
|
|
Collection assignIds = Transform.getIds(previewAssignList, PreviewAssign.class, "id");
|
|
|
- List<UserPaper> userPaperList = userPaperService.listWithCourse(user.getId(), assignIds, id);
|
|
|
+ List<UserPaper> userPaperList = userPaperService.listWithCourse(user.getId(), assignIds, recordId);
|
|
|
Collection paperIds = Transform.getIds(userPaperList, UserPaper.class, "id");
|
|
|
List<UserReport> userReportList = userReportService.listByPaper(paperIds);
|
|
|
tmpList.clear();
|
|
@@ -1820,7 +1951,7 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/course/comment/tips", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "关闭评论提示提示", notes = "关闭评论提示提示", httpMethod = "POST")
|
|
|
- public Response<Boolean> exportTips(@RequestBody @Validated RecordCommentTipsDto dto) {
|
|
|
+ public Response<Boolean> closeCommentTips(@RequestBody @Validated RecordCommentTipsDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserOrderRecord record = userOrderRecordService.get(dto.getRecordId());
|
|
|
userOrderRecordService.edit(UserOrderRecord.builder()
|