From 8c99e2d8b6c1e0d9cde6abbe80b4df75be19f6d1 Mon Sep 17 00:00:00 2001 From: Administrator <2863138610@qq.com> Date: 星期二, 29 十一月 2022 16:31:18 +0800 Subject: [PATCH] 课程与课件bug修复 --- src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java | 62 +++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java b/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java index 9fc2b12..b6057e2 100644 --- a/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java +++ b/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java @@ -2,7 +2,9 @@ import java.util.List; +import com.qxueyou.scc.admin.classes.model.ClsClassReSubject; import com.qxueyou.scc.admin.classes.service.IClassLectureService; +import com.qxueyou.scc.teach.subject.model.Subject; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; @@ -30,6 +32,7 @@ import com.qxueyou.scc.teach.subject.model.view.MyLectureV; import com.qxueyou.scc.teach.subject.service.ILectureService; import com.qxueyou.scc.teach.subject.service.ISubjectService; +import org.springframework.transaction.annotation.Transactional; @Service public class SubjectLectureService extends CommonAppService implements ILectureService { @@ -177,12 +180,26 @@ lecture.setRemark(res.getRemark()); lecture.setSubjectId(chapter.getSubjectId()); lecture.setResItemId(res.getResId()); - - save(lecture); + subjectService.addLectureCount(lecture.getSubjectId(), 1); + return new Result(true, "success"); + } - subjectService.addLectureCount(chapter.getSubjectId(), 1); - + @Override + public Result addLectureLoad(String sectionId){ + SubjectChapter chapter = read(SubjectChapter.class, sectionId); + String hql = "from Subject where subjectId = ? and deleteFlag is false"; + String subjectId = chapter.getSubjectId(); + Subject subjectOne = findUnique(hql,CollectionUtils.newList(subjectId),Subject.class); + String hqlOne = "from Subject where name = ? and deleteFlag is false"; + List<Subject> subjectTwo = find(hqlOne,CollectionUtils.newList(subjectOne.getName()),Subject.class); + for (Subject s : subjectTwo){ + String hqlTwo = "from ClsClassReSubject where subjectId = ? and deleteFlag is false"; + ClsClassReSubject subject = findUnique(hqlTwo,CollectionUtils.newList(s.getSubjectId()),ClsClassReSubject.class); + if(subject != null){ + subjectService.updateClsSubject(subject.getClassId(),s.getSubjectId(),s.getOrigSubjectId(),s.getTeacherId(),s.getSchoolYear(),s.getTerm()); + } + } return new Result(true, "success"); } @@ -209,7 +226,23 @@ for (String lectureId : lectureIds) { deleteLecture(lectureId); } - + return new Result(true, "success"); + } + @Override + public Result deleteLectureLoad(String[] lectureIds){ + SubjectLecture lecture = read(SubjectLecture.class, lectureIds[0]); + String hql = "from Subject where subjectId = ? and deleteFlag is false"; + String subjectId = lecture.getSubjectId(); + Subject subjectOne = findUnique(hql,CollectionUtils.newList(subjectId),Subject.class); + String hqlOne = "from Subject where name = ? and deleteFlag is false"; + List<Subject> subjectTwo = find(hqlOne,CollectionUtils.newList(subjectOne.getName()),Subject.class); + for (Subject s : subjectTwo){ + String hqlTwo = "from ClsClassReSubject where subjectId = ? and deleteFlag is false"; + ClsClassReSubject subject = findUnique(hqlTwo,CollectionUtils.newList(s.getSubjectId()),ClsClassReSubject.class); + if(subject != null){ + subjectService.updateClsSubject(subject.getClassId(),s.getSubjectId(),s.getOrigSubjectId(),s.getTeacherId(),s.getSchoolYear(),s.getTerm()); + } + } return new Result(true, "success"); } @@ -225,7 +258,6 @@ TraceUtils.setUpdateTrace(lecture); lecture.setDeleteFlag(true); - save(lecture); subjectService.addLectureCount(lecture.getSubjectId(), -1); @@ -268,6 +300,22 @@ Integer pageNum, String type) { StringBuffer hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=?"); List<Object> args = CollectionUtils.newList(chapterId, learnerId); + + if (StringUtils.isNotEmpty(type)) { + hql.append(" and lectureType=?"); + args.add(type); + } + + List<MyLectureV> result = findList(hql.toString(), new Pager(pageSize, pageNum), args, MyLectureV.class); + + return result; + } + + @Override + public List<MyLectureV> listLectureVBySubjectId(String learnerId, String subjectId, String keyword, Integer pageSize, + Integer pageNum, String type) { + StringBuffer hql = new StringBuffer("from MyLectureV where subjectId=? and id.userId=? order by lectureUpdateTime desc"); + List<Object> args = CollectionUtils.newList(subjectId, learnerId); if (StringUtils.isNotEmpty(type)) { hql.append(" and lectureType=?"); @@ -370,7 +418,7 @@ @Override public Result doStudy(String lectureId, Double from, Double to) { String userId = null; - return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, lectureId, from.doubleValue(), to.doubleValue(), + return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, lectureId, from.intValue(), to.intValue(), userId); } -- Gitblit v1.8.0