Commit 75b016ff authored by luzhuang's avatar luzhuang

feat: 打开共享 课程同步 log生成(未测试)

parent d2a05828
...@@ -3,6 +3,7 @@ package org.rcisoft.business.bchapter.dao; ...@@ -3,6 +3,7 @@ package org.rcisoft.business.bchapter.dao;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bchapter.dto.*; import org.rcisoft.business.bchapter.dto.*;
import org.rcisoft.business.bchapter.entity.BChapter; import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bchapter.entity.BPChapter;
import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO; import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
...@@ -496,5 +497,19 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -496,5 +497,19 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"and bf.del_flag!=1 and bf.flag =1 " + "and bf.del_flag!=1 and bf.flag =1 " +
"ORDER BY bc.sort LIMIT 1") "ORDER BY bc.sort LIMIT 1")
String getFirstOssId(String chapterId); String getFirstOssId(String chapterId);
/**
* 根据课程id 查询 bPChapters
*
*/
@Select("select * from b_p_chapter where 1=1 "
+ " and del_flag != 1 and flag = 1 "
+ " and lesson_id = #{lessonId}"
// + " and corp_id = #{corpId}"
)
@ResultMap(value = "BaseResultMap" )
List<BChapter> queryBChaptersByLessonId(String lessonId);
} }
package org.rcisoft.business.bchapter.dao; package org.rcisoft.business.bchapter.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bchapter.entity.BPChapter; import org.rcisoft.business.bchapter.entity.BPChapter;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -24,5 +28,27 @@ public interface BPChapterRepository extends BaseMapper<BPChapter> { ...@@ -24,5 +28,27 @@ public interface BPChapterRepository extends BaseMapper<BPChapter> {
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BPChapter> queryBPChapters(BPChapter bPChapter); List<BPChapter> queryBPChapters(BPChapter bPChapter);
@Insert("<script>" +
" insert into b_p_chapter VALUES " +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
"(#{item.businessId}, #{item.createBy}, #{item.createDate},#{item.updateBy}, #{item.updateDate}, #{item.delFlag}, " +
"#{item.flag}, #{item.remarks}, #{item.chapterName}, #{item.chapterLevel}, #{item.pid}, #{item.chapterUrl}," +
"#{item.mdFile}, #{item.isTest}, #{item.lessonId}, #{item.classHour}, #{item.state}, " +
"#{item.sort}, #{item.corpId}, #{item.automatic}, #{item.experimentType}, #{item.courseTime})" +
"</foreach> </script>")
int insertList(List<BChapter> list);
/**
* 批量删除 课程
* @param list
* @return
*/
@Delete("<script>" +
" delete from b_p_chapter where business_id in " +
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item.businessId} </foreach> "+
"</script>")
int deleteList(List<BChapter> list);
} }
package org.rcisoft.business.bfile.dao; package org.rcisoft.business.bfile.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.bfile.entity.BPFile; import org.rcisoft.business.bfile.entity.BPFile;
import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -25,5 +30,27 @@ public interface BPFileRepository extends BaseMapper<BPFile> { ...@@ -25,5 +30,27 @@ public interface BPFileRepository extends BaseMapper<BPFile> {
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BPFile> queryBPFiles(BPFile bPFile); List<BPFile> queryBPFiles(BPFile bPFile);
@Insert("<script>" +
" insert into b_p_file VALUES " +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
"(#{item.businessId},#{item.lessonId},#{item.chapterId},#{item.fileName},#{item.videoUrl}, " +
"#{item.fileUrl},#{item.fileSize},#{item.fileTime}, #{item.type}, #{item.flag}, #{item.delFlag}," +
"#{item.remarks},#{item.createBy},#{item.updateBy},#{item.updateDate},#{item.createDate})" +
"</foreach> </script>")
int insertList(List<BFile> list);
/**
* 批量删除 课程
* @param list
* @return
*/
@Delete("<script>" +
" delete from b_p_file where business_id in " +
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item.businessId} </foreach> "+
"</script>")
int deleteList(List<BFile> list);
} }
...@@ -1281,5 +1281,15 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -1281,5 +1281,15 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and corp_id = #{corpId} ") " and corp_id = #{corpId} ")
@ResultMap(value = "BasePushResultMap") @ResultMap(value = "BasePushResultMap")
List<BLesson> queryPush(String corpId); List<BLesson> queryPush(String corpId);
/**
* 查询 企业下 lessons
* @param corpId
* @return
*/
@Select(" select * from b_lesson where flag = 1 and lesson_type = 0 and release_state in (2,4) and corp_id = #{corpId} ")
@ResultMap(value = "BaseResultMap")
List<BLesson> getLessons(@Param("corpId") String corpId);
} }
package org.rcisoft.business.blesson.dao; package org.rcisoft.business.blesson.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BPLesson; import org.rcisoft.business.blesson.entity.BPLesson;
import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -25,5 +28,31 @@ public interface BPLessonRepository extends BaseMapper<BPLesson> { ...@@ -25,5 +28,31 @@ public interface BPLessonRepository extends BaseMapper<BPLesson> {
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BPLesson> queryBPLessons(BPLesson bPLesson); List<BPLesson> queryBPLessons(BPLesson bPLesson);
@Insert("<script>" +
" insert into b_p_lesson VALUES " +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
"(#{item.businessId}, #{item.code}, #{item.lessonName},#{item.defaultUrl}, #{item.createBy}, #{item.updateBy}, " +
"#{item.delFlag}, #{item.flag}, #{item.remarks}, #{item.updateDate}, #{item.createDate}, #{item.classHour}," +
"#{item.lecturerId}, #{item.releaseState}, #{item.courseId}, #{item.personNumber}, #{item.courseTime}, " +
"#{item.courseDescription}, #{item.viewRange}, #{item.releaseDate}, #{item.closeDate}, #{item.lessonType}," +
"#{item.discussNumber}, #{item.recommend}, #{item.collectNumber}, #{item.hotNumber}, #{item.corpId}, " +
"#{item.applyStartDate}, #{item.applyOverDate}, #{item.trainStartDate}, #{item.trainOverDate}, #{item.maxApplyPerson}, " +
"#{item.trainAddress},#{item.trainSignTime},#{item.qrCode},#{item.valueConsume},#{item.valueGain}, #{item.valueUpdateDate})" +
"</foreach> </script>")
int insertList(List<BLesson> list);
/**
* 批量删除 课程
* @param list
* @return
*/
@Delete("<script>" +
" delete from b_p_lesson where business_id in " +
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item.businessId} </foreach> "+
"</script>")
int deleteList(List<BLesson> list);
} }
...@@ -10,6 +10,7 @@ public enum ReleaseStateEnum { ...@@ -10,6 +10,7 @@ public enum ReleaseStateEnum {
UNRELEASED("0"), UNRELEASED("0"),
RELEASED("2"), RELEASED("2"),
CLOSED("4"), CLOSED("4"),
DELETE("5"),
; ;
ReleaseStateEnum(String code) { ReleaseStateEnum(String code) {
......
package org.rcisoft.business.blessonlog.dao; package org.rcisoft.business.blessonlog.dao;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.blessonlog.entity.BLessonLog; import org.rcisoft.business.blessonlog.entity.BLessonLog;
import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.ResultMap;
...@@ -26,5 +27,14 @@ public interface BLessonLogRepository extends BaseMapper<BLessonLog> { ...@@ -26,5 +27,14 @@ public interface BLessonLogRepository extends BaseMapper<BLessonLog> {
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BLessonLog> queryBLessonLogs(BLessonLog bLessonLog); List<BLessonLog> queryBLessonLogs(BLessonLog bLessonLog);
@Insert("<script>" +
" insert into b_lesson_log VALUES " +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
"(#{item.businessId}, #{item.content}, #{item.lessonId}, #{item.createBy}, #{item.createDate}, " +
"#{item.updateBy}, #{item.updateDate}, #{item.delFlag}, #{item.flag}, #{item.remarks}, #{item.corpId})" +
"</foreach> </script>")
int insertList(List<BLessonLog> list);
} }
...@@ -63,7 +63,7 @@ public class BMessageController extends PaginationController<BMessage> { ...@@ -63,7 +63,7 @@ public class BMessageController extends PaginationController<BMessage> {
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping("/update") @PostMapping("/update")
public Result update(CurUser curUser,@Valid BMessage bMessage, BindingResult bindingResult) { public Result update(CurUser curUser,@Valid BMessage bMessage, BindingResult bindingResult) {
PersistModel data = bMessageServiceImpl.merge(bMessage); PersistModel data = bMessageServiceImpl.merge(curUser,bMessage);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -31,7 +31,7 @@ public interface BMessageService { ...@@ -31,7 +31,7 @@ public interface BMessageService {
* @param bMessage * @param bMessage
* @return * @return
*/ */
PersistModel merge(BMessage bMessage); PersistModel merge(CurUser curUser , BMessage bMessage);
/** /**
* 根据id查询 * 根据id查询
......
package org.rcisoft.business.bmessage.service.impl; package org.rcisoft.business.bmessage.service.impl;
import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.dao.BPChapterRepository;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.dao.BPFileRepository;
import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.dao.BPLessonRepository;
import org.rcisoft.business.blesson.dto.LessonAllDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.enums.ReleaseStateEnum;
import org.rcisoft.business.blessonlog.dao.BLessonLogRepository;
import org.rcisoft.business.blessonlog.entity.BLessonLog;
import org.rcisoft.core.constant.DelStatus;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
...@@ -16,6 +30,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -16,6 +30,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -29,6 +44,22 @@ public class BMessageServiceImpl implements BMessageService { ...@@ -29,6 +44,22 @@ public class BMessageServiceImpl implements BMessageService {
@Autowired @Autowired
private BMessageRepository bMessageRepository; private BMessageRepository bMessageRepository;
@Autowired
private BLessonLogRepository bLessonLogRepository;
@Autowired
private BLessonRepository bLessonRepository;
@Autowired
private BChapterRepository bChapterRepository;
@Autowired
private BFileRepository bFileRepository;
@Autowired
private BPLessonRepository bpLessonRepository;
@Autowired
private BPChapterRepository bpChapterRepository;
@Autowired
private BPFileRepository bpFileRepository;
/** /**
...@@ -66,7 +97,15 @@ public class BMessageServiceImpl implements BMessageService { ...@@ -66,7 +97,15 @@ public class BMessageServiceImpl implements BMessageService {
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel merge(BMessage bMessage){ public PersistModel merge(CurUser curUser , BMessage bMessage){
//判断是否修改课程共享状态
if(bMessage.getSort() == 8){
sendLog(curUser,bMessage);
//开启共享时同步课程
if("1".equals(bMessage.getTimeValue()))
sycnBPLesson(curUser);
}
UserUtil.setCurrentMergeOperation(bMessage); UserUtil.setCurrentMergeOperation(bMessage);
int line = bMessageRepository.updateByPrimaryKeySelective(bMessage); int line = bMessageRepository.updateByPrimaryKeySelective(bMessage);
return new PersistModel(line); return new PersistModel(line);
...@@ -98,4 +137,57 @@ public class BMessageServiceImpl implements BMessageService { ...@@ -98,4 +137,57 @@ public class BMessageServiceImpl implements BMessageService {
// return bMessageRepository.queryBMessages(bMessage); // return bMessageRepository.queryBMessages(bMessage);
// } // }
/**
* 生成课程日志
* @param curUser
* @param bMessage
*/
public void sendLog(CurUser curUser ,BMessage bMessage){
//查询当前企业所有已发布已关闭和删除(曾经是已关闭和已发布)的课程
List<BLesson> lessons = bLessonRepository.getLessons(curUser.getCorpId());
List<BLessonLog> list = new ArrayList<>();
//将操作日志添加到每一个课程
for(BLesson lesson : lessons){
BLessonLog log = new BLessonLog();
UserUtil.setCurrentPersistOperation(log);
log.setContent("1".equals(bMessage.getTimeValue())?"开启共享":"关闭共享");
log.setLessonId(lesson.getBusinessId());
list.add(log);
}
bLessonLogRepository.insertList(list);
}
/**
* 将企业的发布课程保存到 平台中
* @param curUser
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
public void sycnBPLesson(CurUser curUser){
//step1 查询当前企业已发布的课程
List<BLesson> lessons = bLessonRepository.getLessons(curUser.getCorpId());
List<BChapter> chapters = new ArrayList<>();
List<BFile> files = new ArrayList<>();
//step2 根据课程查询对应的章节和课件
lessons.forEach(lesson->{
if(DelStatus.DELETED.getStatus().equals(lesson.getDelFlag())){
lesson.setDelFlag(DelStatus.NORMAL.getStatus());
lesson.setReleaseState(ReleaseStateEnum.DELETE.getCode());
}
List<BChapter> chapterList = bChapterRepository.queryBChaptersByLessonId(lesson.getBusinessId());
List<BFile> fileList = bFileRepository.getFileByLessonId(lesson.getBusinessId());
chapters.addAll(chapterList);
files.addAll(fileList);
});
//step3 将数据插入 缓存课程、章节、课件 表中(全删全加)
bpLessonRepository.deleteList(lessons);
bpChapterRepository.deleteList(chapters);
bpFileRepository.deleteList(files);
bpLessonRepository.insertList(lessons);
bpChapterRepository.insertList(chapters);
bpFileRepository.insertList(files);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment