|
@@ -1,12 +1,14 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
|
|
|
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentCourseHomeworkReplyDao;
|
|
|
import com.ym.mec.biz.dal.dto.Mapper;
|
|
|
import com.ym.mec.biz.dal.dto.TeacherHomeworkListDto;
|
|
|
import com.ym.mec.biz.dal.dto.WebCourseHomeworkListDto;
|
|
|
import com.ym.mec.biz.dal.entity.CourseHomework;
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
import com.ym.mec.biz.dal.entity.StudentCourseHomework;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
@@ -15,11 +17,13 @@ import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
|
|
|
import com.ym.mec.biz.service.CourseHomeworkService;
|
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -43,6 +47,8 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
|
|
|
|
|
|
@Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleDao courseScheduleDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, CourseHomework> getDAO() {
|
|
@@ -50,6 +56,44 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void addCourseHomework(CourseHomework courseHomework) {
|
|
|
+ if(Objects.isNull(courseHomework.getCourseScheduleId())){
|
|
|
+ throw new BizException("课程不存在");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(courseHomework.getContent())){
|
|
|
+ throw new BizException("请填写作业内容");
|
|
|
+ }
|
|
|
+ CourseSchedule courseSchedule = courseScheduleDao.get(courseHomework.getCourseScheduleId());
|
|
|
+ if(Objects.isNull(courseSchedule)){
|
|
|
+ throw new BizException("课程不存在");
|
|
|
+ }
|
|
|
+ Date date=new Date();
|
|
|
+ CourseHomework oldCourseHomework = courseHomeworkDao.findByCourseSchedule(courseHomework.getCourseScheduleId());
|
|
|
+ if(Objects.isNull(oldCourseHomework)){
|
|
|
+ //新增课堂作业
|
|
|
+ oldCourseHomework=courseHomework;
|
|
|
+ oldCourseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ oldCourseHomework.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ oldCourseHomework.setGroupType(courseSchedule.getGroupType());
|
|
|
+ oldCourseHomework.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ oldCourseHomework.setExpiryDate(DateUtil.addDays(date,7));
|
|
|
+ oldCourseHomework.setExpectNum(courseScheduleDao.countCourseStudentNum(courseSchedule.getId()));
|
|
|
+ courseHomeworkDao.insert(oldCourseHomework);
|
|
|
+ List<StudentCourseHomework> studentCourseHomeworks = studentCourseHomeworkDao
|
|
|
+ .constructInitialStudentHomeworkRecordsWithPayment(courseSchedule.getId(),
|
|
|
+ oldCourseHomework.getId());
|
|
|
+ if(CollectionUtils.isEmpty(studentCourseHomeworks)){
|
|
|
+ throw new BizException("此课程没有学生");
|
|
|
+ }
|
|
|
+ studentCourseHomeworkDao.batchInsertStudentCourseHomeworkRecord(studentCourseHomeworks);
|
|
|
+ }else{
|
|
|
+ oldCourseHomework.setContent(courseHomework.getContent());
|
|
|
+ oldCourseHomework.setAttachments(courseHomework.getAttachments());
|
|
|
+ courseHomeworkDao.update(oldCourseHomework);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<Map<String, Object>> findTeacherCourseHomeworkByClassGroup(CourseHomeworkQueryInfo queryInfo) {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|