|
@@ -28,10 +28,7 @@ import com.qxgmat.help.AiHelp;
|
|
|
import com.qxgmat.help.MailHelp;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
import com.qxgmat.service.*;
|
|
|
-import com.qxgmat.service.extend.CourseExtendService;
|
|
|
-import com.qxgmat.service.extend.OrderFlowService;
|
|
|
-import com.qxgmat.service.extend.QuestionFlowService;
|
|
|
-import com.qxgmat.service.extend.SentenceService;
|
|
|
+import com.qxgmat.service.extend.*;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -80,6 +77,9 @@ public class MyController {
|
|
|
private MailHelp mailHelp;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PreviewService previewService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private SettingService settingService;
|
|
|
|
|
|
@Autowired
|
|
@@ -119,6 +119,9 @@ public class MyController {
|
|
|
private CourseDataHistoryService courseDataHistoryService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private CourseTeacherService courseTeacherService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private FaqService faqService;
|
|
|
|
|
|
@Autowired
|
|
@@ -134,6 +137,12 @@ public class MyController {
|
|
|
private UserCourseRecordService userCourseRecordService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private UserCourseAppointmentService userCourseAppointmentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserCourseProgressService userCourseProgressService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private UserSentenceRecordService userSentenceRecordService;
|
|
|
|
|
|
@Autowired
|
|
@@ -193,6 +202,9 @@ public class MyController {
|
|
|
@Autowired
|
|
|
private OrderFlowService orderFlowService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MessageExtendService messageExtendService;
|
|
|
+
|
|
|
@RequestMapping(value = "/email", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "绑定邮箱", httpMethod = "POST")
|
|
|
public Response<Boolean> email(@RequestBody @Validated UserEmailDto dto, HttpSession session, HttpServletRequest request) {
|
|
@@ -316,12 +328,7 @@ public class MyController {
|
|
|
@ApiOperation(value = "发送邮件邀请", httpMethod = "POST")
|
|
|
public Response<Boolean> inviteEmail(@RequestBody @Validated InviteEmailDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- mailHelp.sendBaseMail(
|
|
|
- Strings.join(Arrays.stream(dto.getEmails()).collect(Collectors.toList()), ';'),
|
|
|
- "邮件邀请",
|
|
|
- "",
|
|
|
- map);
|
|
|
+ messageExtendService.sendInviteEmail(dto.getEmails(), user.getInviteCode());
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
@@ -1393,7 +1400,8 @@ public class MyController {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
entity.setUserId(user.getId());
|
|
|
entity.setMessage(1);
|
|
|
- entity.setEmail(user.getEmail());
|
|
|
+ // 取消邮箱发送
|
|
|
+// entity.setEmail(user.getEmail());
|
|
|
faqService.add(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
@@ -1436,7 +1444,7 @@ public class MyController {
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = false) Integer structId,
|
|
|
@RequestParam(required = false) String dataType,
|
|
|
- @RequestParam(required = false, defaultValue = "id") String order,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order, // latest_time, sale_number
|
|
|
@RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
@@ -1445,4 +1453,109 @@ public class MyController {
|
|
|
|
|
|
return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/list", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "购买的课程记录", httpMethod = "GET")
|
|
|
+ public Response<PageMessage<UserCourseDetailDto>> listCourse(
|
|
|
+ @RequestParam(required = false, defaultValue = "1") int page,
|
|
|
+ @RequestParam(required = false, defaultValue = "100") int size,
|
|
|
+ @RequestParam(required = false) String courseModule,
|
|
|
+ @RequestParam(required = false) Boolean isUsed,
|
|
|
+ @RequestParam(required = false) Boolean isEnd,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order, // useEndTime desc
|
|
|
+ @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
+ HttpSession session) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ Page<UserOrderRecord> p = userOrderRecordService.listWithCourse(page, size, user.getId(), CourseModule.ValueOf(courseModule), isUsed, isEnd, order, DirectionStatus.ValueOf(direction));
|
|
|
+ List<UserCourseDetailDto> pr = Transform.convert(p, UserCourseDetailDto.class);
|
|
|
+
|
|
|
+ Collection recordIds = Transform.getIds(p, UserOrderRecord.class,"id");
|
|
|
+
|
|
|
+ // 绑定课程
|
|
|
+ Collection courseIds = Transform.getIds(p, UserOrderRecord.class, "productId");
|
|
|
+ List<Course> courseList = courseService.select(courseIds);
|
|
|
+ Transform.combine(pr, courseList, UserCourseDetailDto.class, "productId", "course", Course.class, "id", CourseExtendDto.class);
|
|
|
+
|
|
|
+ // 绑定课时、预约、进度
|
|
|
+ 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);
|
|
|
+
|
|
|
+ Map<Object, Collection<UserCourseProgress>> progressMap = userCourseProgressService.groupByRecordId(recordIds);
|
|
|
+ for(UserCourseDetailDto dto : pr){
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取每个科目的所有作业
|
|
|
+ Map<Object, Collection<UserPreviewPaperRelation>> previewMap = previewService.groupByCourseId(user.getId(), recordIds, 1000);
|
|
|
+ Transform.combine(pr, previewMap, UserCourseDetailDto.class, "productId", "papers", UserPaperBaseExtendDto.class);
|
|
|
+
|
|
|
+ // 绑定老师
|
|
|
+ Collection teacherIds = Transform.getIds(p, UserOrderRecord.class, "teacherId");
|
|
|
+ List<CourseTeacher> teacherList = courseTeacherService.select(teacherIds);
|
|
|
+ Transform.combine(pr, teacherList, UserCourseDetailDto.class, "teacherId", "teacher", CourseTeacher.class, "id", CourseTeacherExtendDto.class);
|
|
|
+
|
|
|
+
|
|
|
+ return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/suspend", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "申请停课", notes = "申请停课", httpMethod = "POST")
|
|
|
+ public Response<Boolean> suspendCourse(@RequestBody @Validated CourseSuspendDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ courseExtendService.suspendCourse(user.getId(), dto.getRecordId());
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/restore", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "恢复停课", notes = "恢复停课", httpMethod = "POST")
|
|
|
+ public Response<Boolean> restoreCourse(@RequestBody @Validated CourseRestoreDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ courseExtendService.restoreCourse(user.getId(), dto.getRecordId());
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/time", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "时间表", notes = "时间表", httpMethod = "GET")
|
|
|
+ public Response<List<UserCourseTimeDto>> timeCourse(int id) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ List<UserCourseTimeDto> dtos = new ArrayList<>();
|
|
|
+
|
|
|
+ UserOrderRecord record = userOrderRecordService.get(id);
|
|
|
+ if (record == null){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+ if (!record.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取停课记录
|
|
|
+ Date suspend = record.getSuspendTime();
|
|
|
+ if (suspend != null){
|
|
|
+ Date restore = record.getRestoreTime();
|
|
|
+ if (restore == null) restore = new Date();
|
|
|
+
|
|
|
+ while(suspend.before(restore)){
|
|
|
+ UserCourseTimeDto dto = new UserCourseTimeDto();
|
|
|
+ dto.setType("stop");
|
|
|
+ dto.setDay(Tools.day(suspend));
|
|
|
+ dtos.add(dto);
|
|
|
+ suspend = Tools.addDate(suspend, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 获取听课记录
|
|
|
+
|
|
|
+ return ResponseHelp.success(dtos);
|
|
|
+ }
|
|
|
}
|