From 6ca7ca9feb1cc4a35cab3a3af8dddfae2580bddc Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期四, 08 十二月 2022 14:17:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/main/java/com/qxueyou/scc/admin/classes/service/impl/ClassLectureService.java | 201 +++++++++++++++++++++++++++----------------------
1 files changed, 110 insertions(+), 91 deletions(-)
diff --git a/src/main/java/com/qxueyou/scc/admin/classes/service/impl/ClassLectureService.java b/src/main/java/com/qxueyou/scc/admin/classes/service/impl/ClassLectureService.java
index 4f55be4..18a3e55 100644
--- a/src/main/java/com/qxueyou/scc/admin/classes/service/impl/ClassLectureService.java
+++ b/src/main/java/com/qxueyou/scc/admin/classes/service/impl/ClassLectureService.java
@@ -52,7 +52,7 @@
@Service
public class ClassLectureService extends CommonAppService implements IClassLectureService {
-
+
private final Logger log = LogManager.getLogger(ClassLectureService.class);
@Autowired
@@ -69,7 +69,7 @@
@Autowired
ProgressDAO progressDao;
-
+
@Autowired
IMsgInfoService msgInfoService;
@@ -95,41 +95,47 @@
@Override
public List<MyLectureV> listLectureV(String learnerId, String chapterId, String keyword, Integer pageSize,
Integer pageNum, String type) {
- StringBuffer hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=? and status=? order by lectureCreateTime desc");
- List<Object> args = CollectionUtils.newList(chapterId, learnerId,ClsSubjectLecture.STATUS_DRAFT);
+ StringBuffer hql = new StringBuffer("from MyLectureV where subjectId=? and id.userId=?");
+ List<Object> args = CollectionUtils.newList(chapterId, learnerId);
+ List<MyLectureV> myLectureVList = findList(hql.toString(), new Pager(pageSize, pageNum), args, MyLectureV.class);
+
+ if(myLectureVList.size() < 1){
+
+ }else {
+ hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=? order by lectureCreateTime desc");
+ args = CollectionUtils.newList(myLectureVList.get(0).getChapterId(), 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 Map<String,Object> listLectureBySubjectOrderCreateTime(String subjectId, String classId, String sort, Pager pager) {
Subject subject = this.read(Subject.class, subjectId);
- if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType()) {//公开课课件
+ if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType()) {//鍏紑璇捐浠�
return this.listOpenLectureBySubjectOrderCreateTime(subjectId, sort, pager);
}
-
+
QMyLectureV qMyLectureV = QMyLectureV.myLectureV;
-
+
OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qMyLectureV.lectureCreateTime):
new OrderSpecifier<Date>(Order.ASC, qMyLectureV.lectureCreateTime);
-
+
JPAQuery<MyLectureV> query = this.getQueryFactory().selectFrom(qMyLectureV)
.where(qMyLectureV.subjectId.eq(subjectId).
and(qMyLectureV.classId.eq(classId)).and(qMyLectureV.id.userId.eq(ClientUtils.getUserId())));
-
+
long count = query.fetchCount();
-
+
return CollectionUtils.newObjectMap("count", count, "listData", query.limit(pager.getPageSize()).offset(pager.getOffset())
.orderBy(order)
.fetch().stream()
@@ -144,10 +150,10 @@
return map;
}).collect(Collectors.toList()));
}
-
+
/**
- * 公开课课件
- *
+ * 鍏紑璇捐浠�
+ *
* @param subjectId
* @param sort
* @param pager
@@ -157,14 +163,14 @@
public Map<String,Object> listOpenLectureBySubjectOrderCreateTime(String subjectId, String sort, Pager pager) {
QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture;
QProgress qProgress = QProgress.progress;
-
+
OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qSubjectLecture.createTime):
new OrderSpecifier<Date>(Order.ASC, qSubjectLecture.createTime);
-
+
JPAQuery<SubjectLecture> query = this.getQueryFactory().selectFrom(qSubjectLecture).where(qSubjectLecture.subjectId.eq(subjectId).and(qSubjectLecture.deleteFlag.isFalse()).and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT)));
-
+
long count = query.fetchCount();
-
+
return CollectionUtils.newObjectMap("count", count, "listData", query.limit(pager.getPageSize()).offset(pager.getOffset())
.orderBy(order)
.fetch().stream()
@@ -201,9 +207,9 @@
}
/**
- * 删除单个章节
+ * 鍒犻櫎鍗曚釜绔犺妭
*
- * @param chapterId 章节id
+ * @param chapterId 绔犺妭id
* @return
*/
private Result deleteChapter(String chapterId) {
@@ -236,34 +242,47 @@
lecture.setClassId(chapter.getClassId());
lecture.setStatus(res.getStatus());
save(lecture);
-
- // 发送消息
+
+ // 鍙戦�佹秷鎭�
doPublishMsg(lecture);
return new Result(true, "success");
}
-
- //添加课程,发送消息
+
+ //娣诲姞璇剧▼锛屽彂閫佹秷鎭�
private void doPublishMsg(ClsSubjectLecture lecture){
Subject subject = this.read(Subject.class, lecture.getSubjectId());
-
+
if(!subject.getStatus().equals(Subject.STATUS_ISSUED)){
return ;
}
-
- //查询直播关联的班级
+
+ //鏌ヨ鐩存挱鍏宠仈鐨勭彮绾�
String hql = "select userId from StuStudent where classId =:classId and deleteFlag is false ";
-
+
List<String> lstUserIds = this.findByComplexHql(hql, CollectionUtils.newObjectMap("classId",lecture.getClassId()), String.class);
-
+
if(lstUserIds!=null && lstUserIds.size()>0){
Map<String,String> attrs = CollectionUtils.newStringMap("lectureId",lecture.getLectureId(),"lectureName",lecture.getName(),"subjectId",subject.getSubjectId(),
"lectureType",lecture.getLectureType(),"subjectName",subject.getName());
-
- msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]),MsgInfo.TYPE_COURSEWARE,"发布了课件",attrs);
+
+ msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]),MsgInfo.TYPE_COURSEWARE,"鍙戝竷浜嗚浠�",attrs);
}
}
+ public Result updateLecturetime(String targetId) {
+
+ ClsSubjectLecture lecture = read(ClsSubjectLecture.class, targetId);
+
+
+ TraceUtils.setUpdateTrace(lecture);
+
+ lecture.setUpdateTime(new Date());
+ lecture.setUpdator(ClientUtils.getUserId());
+ save(lecture);
+
+ return new Result(true, "success");
+ }
@Override
public Result updateLecture(String lectureId, String resId) {
@@ -292,7 +311,7 @@
}
/**
- * @param lectureId 课件id
+ * @param lectureId 璇句欢id
* @return
*/
private Result deleteLecture(String lectureId) {
@@ -301,7 +320,7 @@
TraceUtils.setUpdateTrace(lecture);
lecture.setDeleteFlag(true);
save(lecture);
- deleteProgress(lectureId);// 删除对应的进度
+ deleteProgress(lectureId);// 鍒犻櫎瀵瑰簲鐨勮繘搴�
return new Result(true, "success");
}
@@ -345,7 +364,7 @@
return result;
}
-
+
@Override
public List<Map<String, Object>> listLectureBySubject(String subjectId, String type, String classId) {
StringBuffer hql = new StringBuffer("select name as lectureName, "
@@ -366,8 +385,8 @@
return this.findListWithMapByHql(hql.toString(), args);
}
-
-
+
+
@Override
public List<Map<String, Object>> listStuLectureBySubject(String subjectId, String classId) {
if(StringUtils.isEmpty(subjectId) || StringUtils.isEmpty(classId)) {
@@ -390,10 +409,10 @@
return map;
}).collect(Collectors.toList());
}
-
+
/**
- * 我的公开课课件查询
- *
+ * 鎴戠殑鍏紑璇捐浠舵煡璇�
+ *
* @param subjectId
* @return
*/
@@ -418,10 +437,10 @@
return map;
}).collect(Collectors.toList());
}
-
+
/**
- * 查询数量
- *
+ * 鏌ヨ鏁伴噺
+ *
* @param subjectId
* @param classId
* @return
@@ -440,7 +459,7 @@
ClsSubjectLecture lecture = read(ClsSubjectLecture.class, lectureId);
String resItemId = null;
if(lecture == null) {
- resItemId = read(SubjectLecture.class, lectureId).getResItemId();//班级课件
+ resItemId = read(SubjectLecture.class, lectureId).getResItemId();//鐝骇璇句欢
}else {
resItemId = lecture.getResItemId();
}
@@ -488,7 +507,7 @@
return result;
}
-
+
public List<SubjectChapter> getListOpenChapter(String subjectId) {
StringBuffer hql = new StringBuffer(
@@ -506,18 +525,18 @@
return result;
}
-
+
@Override
public Result doClearLecturesToClass( String classId,String subjectId) {
this.bulkUpdate("update ClsSubjectLecture set deleteFlag = true where classId=? and subjectId = ? ",
new String[]{classId,subjectId});
-
+
this.bulkUpdate("update ClsSubjectChapter set deleteFlag = true where classId=? and subjectId = ? ",
new String[]{classId,subjectId});
-
+
return new Result(true);
}
-
+
@Override
public Result doCopyLecturesToClass(String origSubjectId, String subjectId, String classId) {
Map<String, String> subjectIdMap = CollectionUtils.newStringMap(SubjectChapter.ROOT_CHAPTER_ID,
@@ -567,7 +586,7 @@
@Override
public List<ClsSubjectLecture> listLecture(String subjectId) {
-
+
StringBuffer hql = new StringBuffer("from ClsSubjectLecture where subjectId = ? and deleteFlag is false");
List<Object> args = CollectionUtils.newList(subjectId);
@@ -575,30 +594,30 @@
return find(hql.toString(), args, ClsSubjectLecture.class);
}
-
+
@Override
public Result listSubjectLecture(String classId, String sort, Pager pager) {
if(StringUtils.isEmpty(classId)) {
- return new Result(false, "班级id不能为空");
+ return new Result(false, "鐝骇id涓嶈兘涓虹┖");
}
QMyLectureV qMyLectureV = QMyLectureV.myLectureV;
-
+
OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qMyLectureV.lectureCreateTime):
new OrderSpecifier<Date>(Order.ASC, qMyLectureV.lectureCreateTime);
-
+
JPAQuery<MyLectureV> query = this.getQueryFactory()
.selectFrom(qMyLectureV)
.where(new QueryDslOptionBuilder()
.and(qMyLectureV.classId::eq, classId).and(qMyLectureV.id.userId::eq,ClientUtils.getUserId())
.build()
);
-
+
long count = query.fetchCount();
-
- // 获取查询结果集合
+
+ // 鑾峰彇鏌ヨ缁撴灉闆嗗悎
QueryResults<MyLectureV> results = query.limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(order).fetchResults();
-
- List<Map<String,Object>> resultLst =
+
+ List<Map<String,Object>> resultLst =
results.getResults()
.stream()
.map(tuple -> {
@@ -629,7 +648,7 @@
}
/**
- * 删除对应的课件
+ * 鍒犻櫎瀵瑰簲鐨勮浠�
*
* @param chapterId
* @return
@@ -641,11 +660,11 @@
return new Result(true);
}
-
-
+
+
/**
- * 获取章节下的课件
- *
+ * 鑾峰彇绔犺妭涓嬬殑璇句欢
+ *
* @param chapterLst
* @param lectures
* @return
@@ -659,9 +678,9 @@
}
}
}
-
+
this.getTopChapters(chapterLst);
-
+
for (int i=chapterLst.size()-1;i>=0;i--) {
ClsSubjectChapter objClsSubjectChapter = chapterLst.get(i);
if(objClsSubjectChapter.getLectures() == null || objClsSubjectChapter.getLectures().isEmpty()) {
@@ -669,13 +688,13 @@
}
}
}
-
+
return chapterLst;
}
-
+
/**
- * 获取章节的第一层数据
- *
+ * 鑾峰彇绔犺妭鐨勭涓�灞傛暟鎹�
+ *
* @param chapterLst
* @return
*/
@@ -702,11 +721,11 @@
chapterLst = this.getTopChapters(chapterLst);
}
}
-
+
return chapterLst;
}
-
-
+
+
@Override
public int readDocPageCount(String resItemId) {
ResItemDoc resItemDoc = read(ResItemDoc.class, resItemId);
@@ -721,10 +740,10 @@
return schHandout.getPageCount();
}
-
+
/**
- * 课件按目录分类
- *
+ * 璇句欢鎸夌洰褰曞垎绫�
+ *
* @param classId
* @param subjectId
* @param type
@@ -732,12 +751,12 @@
*/
public Result coursewareChapterList(String classId,String subjectId, String type) {
Subject subject = this.read(Subject.class, subjectId);
-
- if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType() || Subject.TYPE_ORG_SUBJECT == subject.getType()) {//公开课和管理员课程
+
+ if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType() || Subject.TYPE_ORG_SUBJECT == subject.getType()) {//鍏紑璇惧拰绠$悊鍛樿绋�
QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture;
- //课件
+ //璇句欢
List<Map<String, Object>> lectures = this.listStuLectureByOpenSubject(subjectId);
-
+
List<SubjectChapter> lstSubjectChapterLst = this.getListOpenChapter(subjectId);
List<ClsSubjectChapter> lstClsSubjectChapter = new ArrayList<>();
if(lstSubjectChapterLst != null && !lstSubjectChapterLst.isEmpty()) {
@@ -747,28 +766,28 @@
try {
BeanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter);
} catch (IllegalAccessException e) {
- log.error("拷贝属性失败BeanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter)", e);
+ log.error("鎷疯礉灞炴�уけ璐eanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter)", e);
} catch (InvocationTargetException e) {
- log.error("拷贝属性失败BeanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter)", e);
+ log.error("鎷疯礉灞炴�уけ璐eanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter)", e);
}
-
+
lstClsSubjectChapter.add(objClsSubjectChapter);
}
}
- //章节
+ //绔犺妭
List<ClsSubjectChapter> chapterLst = this.getChapterLectures(lstClsSubjectChapter, lectures);
-
+
long count = this.getQueryFactory().selectFrom(qSubjectLecture)
.where(qSubjectLecture.subjectId.eq(subjectId).and(qSubjectLecture.deleteFlag.isFalse()).
and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))).fetchCount();
return new Result(true, "success", CollectionUtils.newObjectMap("count",count, "listData", QBeanUtils.listBean2ListMap(chapterLst,
CollectionUtils.newStringMap("name", "name", "chapterId", "chapterId", "lectures", "lectures"))));
-
+
}else{
- //课件
+ //璇句欢
List<Map<String, Object>> lectures = this.listStuLectureBySubject(subjectId, classId);
- //章节
+ //绔犺妭
List<ClsSubjectChapter> chapterLst = this.getChapterLectures(this.getListChapter(classId, subjectId, null), lectures);
return new Result(true, "success", CollectionUtils.newObjectMap("count",this.stuLectureCountBySubject(subjectId, classId), "listData", QBeanUtils.listBean2ListMap(chapterLst,
--
Gitblit v1.8.0