派生自 projectDept/qhighschool

111
胡仁荣
2022-12-02 b94deda20c9abd2fb6248b831e10a620eb7daf68
src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java
@@ -2,6 +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;
@@ -29,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 {
@@ -46,6 +50,9 @@
   @Autowired
   IProgressService progressService;
   @Autowired
   IClassLectureService clsLectureService;
   @Override
   public Result addChapter(String subjectId, String parentChapterId, String name) {
@@ -87,7 +94,7 @@
   /**
    * 删除单个章节
    *
    *
    * @param chapterId
    *            章节id
    * @return
@@ -138,7 +145,7 @@
   /**
    * 初始化
    *
    *
    * @param subjectId
    * @return
    */
@@ -173,11 +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");
   }
@@ -204,12 +226,28 @@
      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");
   }
   /**
    *
    *
    * @param lectureId
    *            课件id
    * @return
@@ -220,7 +258,6 @@
      TraceUtils.setUpdateTrace(lecture);
      lecture.setDeleteFlag(true);
      save(lecture);
      subjectService.addLectureCount(lecture.getSubjectId(), -1);
@@ -275,16 +312,32 @@
   }
   @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=?");
         args.add(type);
      }
      List<MyLectureV> result = findList(hql.toString(), new Pager(pageSize, pageNum), args, MyLectureV.class);
      return result;
   }
   @Override
   public int listLectureCount(String chapterId, String keyword, String type) {
      StringBuffer hql = new StringBuffer("from SubjectLecture where chapterId=? and name like ? and deleteFlag is false");
      List<Object> args = CollectionUtils.newList(chapterId,'%' + keyword.trim() + '%');
      if (StringUtils.isNotEmpty(type)) {
         hql.append(" and lectureType=?");
         args.add(type);
      }
      return findCount(hql.toString(),args);
   }