Commit 0db857f0 authored by luzhuang's avatar luzhuang

feat: 发布、修改课程 共享

parent 61b8610a
package org.rcisoft.business.bchapter.service.impl; package org.rcisoft.business.bchapter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -7,20 +8,20 @@ import org.apache.commons.collections.map.HashedMap; ...@@ -7,20 +8,20 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository; import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.dao.BPChapterRepository;
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.enums.*; import org.rcisoft.business.bchapter.enums.*;
import org.rcisoft.business.bchapter.service.BChapterService; import org.rcisoft.business.bchapter.service.BChapterService;
import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO; import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO;
import org.rcisoft.business.bfile.dao.BPFileRepository;
import org.rcisoft.business.bfile.dto.uploadDTO; import org.rcisoft.business.bfile.dto.uploadDTO;
import org.rcisoft.business.blesson.dao.BCollectRepository; import org.rcisoft.business.blesson.dao.*;
import org.rcisoft.business.blesson.dao.BLessonPersonRepository;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.dao.BViewrangeRepository;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.bfile.dao.BFileRepository; import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.entity.BFile; import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.blesson.entity.BLessonPerson; import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.blesson.entity.BPLesson;
import org.rcisoft.business.blesson.entity.BViewrange; import org.rcisoft.business.blesson.entity.BViewrange;
import org.rcisoft.business.blesson.enums.IsFinishEnum; import org.rcisoft.business.blesson.enums.IsFinishEnum;
import org.rcisoft.business.blesson.enums.LessonSycnEnum; import org.rcisoft.business.blesson.enums.LessonSycnEnum;
...@@ -42,6 +43,7 @@ import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO; ...@@ -42,6 +43,7 @@ import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO;
import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO; import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.DelStatus;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -113,6 +115,14 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -113,6 +115,14 @@ public class BChapterServiceImpl implements BChapterService {
@Autowired @Autowired
BViewrangeRepository bViewrangeRepository; BViewrangeRepository bViewrangeRepository;
@Autowired
BPLessonRepository bpLessonRepository;
@Autowired
BPChapterRepository bpChapterRepository;
@Autowired
BPFileRepository bpFileRepository;
@Value("${upload.fileMaxSize:100}") @Value("${upload.fileMaxSize:100}")
private Long fileMaxSize; private Long fileMaxSize;
...@@ -581,7 +591,31 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -581,7 +591,31 @@ public class BChapterServiceImpl implements BChapterService {
String flag = bMessageRepository.getSycnValue(model.getCorpId()); String flag = bMessageRepository.getSycnValue(model.getCorpId());
//开启共享状态 编辑课程时 添加日志 //开启共享状态 编辑课程时 添加日志
if(LessonSycnEnum.OPEN.getCode().equals(flag)){ if(LessonSycnEnum.OPEN.getCode().equals(flag)){
bLessonLogRepository.insertSelective(BLessonLog.generate("编辑章节",model.getBusinessId())); // 保存日志
bLessonLogRepository.insertSelective(BLessonLog.generate("修改课程",model.getLessonId()));
//判断 该章节对应课程 的发布状态 (已发布和已关闭才执行以下操作)
BLesson bLesson = bLessonRepository.selectByPrimaryKey(model.getLessonId());
if(ReleaseStateEnum.RELEASED.getCode().equals(bLesson.getReleaseState())
|| ReleaseStateEnum.CLOSED.getCode().equals(bLesson.getReleaseState())){
// 同步 资源共享 更新 缓存章节 文件 两个表(未发布的课程 之前不会被同步到缓存表中)
List<BChapter> chapters = new ArrayList<>();
List<BFile> files = new ArrayList<>();
//step2 根据课程查询对应的章节和课件
if(DelStatus.DELETED.getStatus().equals(bLesson.getDelFlag())){
bLesson.setDelFlag(DelStatus.NORMAL.getStatus());
bLesson.setReleaseState(ReleaseStateEnum.DELETE.getCode());
}
List<BChapter> chapterList = bChapterRepository.queryBChaptersByLessonId(bLesson.getBusinessId());
List<BFile> fileList = bFileRepository.getFileByLessonId(bLesson.getBusinessId());
chapters.addAll(chapterList);
files.addAll(fileList);
//step3 将数据插入 缓存 章节、课件 表(全删全加)
bpChapterRepository.deleteList(chapters);
bpFileRepository.deleteList(files);
bpChapterRepository.insertList(chapters);
bpFileRepository.insertList(files);
}
} }
return new PersistModel(line); return new PersistModel(line);
} }
......
package org.rcisoft.business.blesson.service.impl; package org.rcisoft.business.blesson.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository; 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.bcourse.dao.BCourseRepository; import org.rcisoft.business.bcourse.dao.BCourseRepository;
import org.rcisoft.business.bcourse.dto.AllCourseDTO; import org.rcisoft.business.bcourse.dto.AllCourseDTO;
import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.dao.BPFileRepository;
import org.rcisoft.business.bfile.dao.BTrainFileRepository; import org.rcisoft.business.bfile.dao.BTrainFileRepository;
import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.bfile.entity.BTrainFile; import org.rcisoft.business.bfile.entity.BTrainFile;
import org.rcisoft.business.blabel.dto.QueryLabelResDTO; import org.rcisoft.business.blabel.dto.QueryLabelResDTO;
import org.rcisoft.business.blesson.dao.*; import org.rcisoft.business.blesson.dao.*;
...@@ -42,6 +48,7 @@ import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; ...@@ -42,6 +48,7 @@ import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.common.util.outClient.MTMicroappApiRequestClient; import org.rcisoft.common.util.outClient.MTMicroappApiRequestClient;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient; import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.DelStatus;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.enums.MessageEnum; import org.rcisoft.core.enums.MessageEnum;
import org.rcisoft.core.enums.UrlTypeEnum; import org.rcisoft.core.enums.UrlTypeEnum;
...@@ -144,6 +151,18 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -144,6 +151,18 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
SendNoticeService sendNoticeService; SendNoticeService sendNoticeService;
@Autowired
BPLessonRepository bpLessonRepository;
@Autowired
BPChapterRepository bpChapterRepository;
@Autowired
BPFileRepository bpFileRepository;
@Autowired
BFileRepository bFileRepository;
@Value("${upload.replaceHttp:false}") @Value("${upload.replaceHttp:false}")
private String replaceHttp; private String replaceHttp;
...@@ -450,13 +469,18 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -450,13 +469,18 @@ public class BLessonServiceImpl implements BLessonService {
} }
} else { } else {
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
line = bLessonRepository.updateByPrimaryKeySelective(model);
//查询 当前资源共享状态 //查询 当前资源共享状态
String flag = bMessageRepository.getSycnValue(model.getCorpId()); String flag = bMessageRepository.getSycnValue(model.getCorpId());
//开启共享状态 编辑课程时 添加日志 //开启共享状态 编辑课程时 添加日志
if(LessonSycnEnum.OPEN.getCode().equals(flag) && LessonTypeEnum.LESSON.getCode().equals(model.getLessonType())){ if(LessonSycnEnum.OPEN.getCode().equals(flag) && LessonTypeEnum.LESSON.getCode().equals(model.getLessonType())){
// 保存日志
bLessonLogRepository.insertSelective(BLessonLog.generate("编辑课程",model.getBusinessId())); bLessonLogRepository.insertSelective(BLessonLog.generate("编辑课程",model.getBusinessId()));
// 同步 资源共享 更新 缓存课程 表
BPLesson bpModel = new BPLesson();
BeanUtil.copyProperties(model,bpModel);
bpLessonRepository.updateByPrimaryKeySelective(bpModel);
} }
line = bLessonRepository.updateByPrimaryKeySelective(model);
//若培训结束时间改变 修改学生签到状态 //若培训结束时间改变 修改学生签到状态
//查询课程信息 //查询课程信息
BLesson bLesson = bLessonRepository.selectByPrimaryKey(model.getBusinessId()); BLesson bLesson = bLessonRepository.selectByPrimaryKey(model.getBusinessId());
...@@ -696,6 +720,31 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -696,6 +720,31 @@ public class BLessonServiceImpl implements BLessonService {
bLesson.setReleaseDate(new Date()); bLesson.setReleaseDate(new Date());
UserUtil.setCurrentMergeOperation(bLesson); UserUtil.setCurrentMergeOperation(bLesson);
int line = bLessonRepository.releaseLesson(bLesson); int line = bLessonRepository.releaseLesson(bLesson);
//发布成功 添加日志 和 同步操作
//查询 当前资源共享状态
String flag = bMessageRepository.getSycnValue(curUser.getCorpId());
//开启共享状态 编辑课程时 添加日志
if(LessonSycnEnum.OPEN.getCode().equals(flag) && LessonTypeEnum.LESSON.getCode().equals(bLesson.getLessonType())){
// 保存日志
bLessonLogRepository.insertSelective(BLessonLog.generate("发布课程",bLesson.getBusinessId()));
// 同步 资源共享 更新 缓存课程 章节 文件 三个表(未发布的课程 之前不会被同步到缓存表中)
List<BChapter> chapters = new ArrayList<>();
List<BFile> files = new ArrayList<>();
//step2 根据课程查询对应的章节和课件
if(DelStatus.DELETED.getStatus().equals(bLesson.getDelFlag())){
bLesson.setDelFlag(DelStatus.NORMAL.getStatus());
bLesson.setReleaseState(ReleaseStateEnum.DELETE.getCode());
}
List<BChapter> chapterList = bChapterRepository.queryBChaptersByLessonId(bLesson.getBusinessId());
List<BFile> fileList = bFileRepository.getFileByLessonId(bLesson.getBusinessId());
chapters.addAll(chapterList);
files.addAll(fileList);
BPLesson bpLesson = new BPLesson();
BeanUtil.copyProperties(bLesson,bpLesson);
bpLessonRepository.insertSelective(bpLesson);
bpChapterRepository.insertList(chapters);
bpFileRepository.insertList(files);
}
//查询该讲师发布课程获得积分数 //查询该讲师发布课程获得积分数
CurUser lecCurUser = new CurUser(bLesson.getCorpId(), bLesson.getLecturerId(), null, null); CurUser lecCurUser = new CurUser(bLesson.getCorpId(), bLesson.getLecturerId(), null, null);
List<BReleaseValue> bReleaseValueList = bReleaseValueRepository.selectReleaseValueByPersonId(lecCurUser); List<BReleaseValue> bReleaseValueList = bReleaseValueRepository.selectReleaseValueByPersonId(lecCurUser);
......
...@@ -199,15 +199,13 @@ public class BMessageServiceImpl implements BMessageService { ...@@ -199,15 +199,13 @@ public class BMessageServiceImpl implements BMessageService {
chapters.addAll(chapterList); chapters.addAll(chapterList);
files.addAll(fileList); files.addAll(fileList);
}); });
int line = 0;
//step3 将数据插入 缓存课程、章节、课件 表中(全删全加) //step3 将数据插入 缓存课程、章节、课件 表中(全删全加)
line = bpLessonRepository.deleteList(lessons); bpLessonRepository.deleteList(lessons);
line = bpChapterRepository.deleteList(chapters); bpChapterRepository.deleteList(chapters);
line = bpFileRepository.deleteList(files); bpFileRepository.deleteList(files);
bpLessonRepository.insertList(lessons);
line = bpLessonRepository.insertList(lessons); bpChapterRepository.insertList(chapters);
line = bpChapterRepository.insertList(chapters); bpFileRepository.insertList(files);
line = bpFileRepository.insertList(files);
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<result column="value_update_date" jdbcType="TIMESTAMP" property="valueUpdateDate"/> <result column="value_update_date" jdbcType="TIMESTAMP" property="valueUpdateDate"/>
<result column="is_trans" jdbcType="VARCHAR" property="isTrans"/> <result column="is_trans" jdbcType="VARCHAR" property="isTrans"/>
<result column="from_corp" jdbcType="VARCHAR" property="fromCorp"/> <result column="from_corp" jdbcType="VARCHAR" property="fromCorp"/>
<result column="corp_id" jdbcType="VARCHAR" property="corpId"/>
<!----> <!---->
<collection property="labelList" ofType="org.rcisoft.business.blabel.dto.QueryLabelResDTO" <collection property="labelList" ofType="org.rcisoft.business.blabel.dto.QueryLabelResDTO"
......
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