Commit 9ed57d92 authored by luzhuang's avatar luzhuang

feat: 资源共享开关 时间限制1分钟

parent 3bd5914f
......@@ -504,7 +504,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* 根据课程id 查询 bPChapters
*
*/
@Select("select * from b_p_chapter where 1=1 "
@Select("select * from b_chapter where 1=1 "
+ " and del_flag != 1 and flag = 1 "
+ " and lesson_id = #{lessonId}"
// + " and corp_id = #{corpId}"
......
......@@ -60,7 +60,7 @@ public class BMessageController extends PaginationController<BMessage> {
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")
@PostMapping("/update")
public Result update(CurUser curUser,@Valid BMessage bMessage, BindingResult bindingResult) {
PersistModel data = bMessageServiceImpl.merge(curUser,bMessage);
......@@ -71,14 +71,14 @@ public class BMessageController extends PaginationController<BMessage> {
}
@ApiOperation(value="修改共享 ", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")
@PostMapping("/updateSycn")
public Result updateSycn(CurUser curUser,@Valid BMessage bMessage, BindingResult bindingResult) {
PersistModel data = bMessageServiceImpl.updateSycn(curUser,bMessage);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bMessage);
"1".equals(bMessage.getTimeValue())?"打开共享":"关闭共享");
}
......
package org.rcisoft.business.bmessage.service.impl;
import cn.hutool.core.date.DateUtil;
import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.dao.BPChapterRepository;
import org.rcisoft.business.bchapter.entity.BChapter;
......@@ -13,6 +14,7 @@ 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.exception.ServiceException;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
......@@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
......@@ -108,9 +111,17 @@ public class BMessageServiceImpl implements BMessageService {
* @param bMessage
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
// @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel updateSycn(CurUser curUser , BMessage bMessage){
//先查询 原数据
BMessage oldBMessage = bMessageRepository.selectByPrimaryKey(bMessage.getBusinessId());
Calendar calendar = DateUtil.calendar(oldBMessage.getUpdateDate()); //获取上次操作时间
calendar.add(Calendar.MINUTE,1); //将此文件和当前时间对比
Calendar now = Calendar.getInstance(); //获取当前时间
Long sec = (now.getTimeInMillis() - calendar.getTimeInMillis())/1000;
if(sec <= 0L)
throw new ServiceException(165,"请"+Math.abs(sec)+"秒后再次操作!");
//保存课程日志
sendLog(curUser,bMessage);
//开启共享时同步课程
......@@ -153,16 +164,17 @@ public class BMessageServiceImpl implements BMessageService {
* @param curUser
* @param bMessage
*/
public void sendLog(CurUser curUser ,BMessage bMessage){
public int sendLog(CurUser curUser ,BMessage bMessage){
//查询当前企业所有已发布已关闭和删除(曾经是已关闭和已发布)的课程
List<BLesson> lessons = bLessonRepository.getLessons(curUser.getCorpId());
List<BLessonLog> list = new ArrayList<>();
//将操作日志添加到每一个课程
for(BLesson lesson : lessons){
BLessonLog log = BLessonLog.generate("1".equals(bMessage.getTimeValue())?"开启共享":"关闭共享",lesson.getBusinessId());
BLessonLog log = BLessonLog.generate("1".equals(bMessage.getTimeValue())?"开启资源共享":"关闭资源共享",lesson.getBusinessId());
list.add(log);
}
bLessonLogRepository.insertList(list);
int line = bLessonLogRepository.insertList(list);
return line;
}
/**
......@@ -187,14 +199,15 @@ public class BMessageServiceImpl implements BMessageService {
chapters.addAll(chapterList);
files.addAll(fileList);
});
int line = 0;
//step3 将数据插入 缓存课程、章节、课件 表中(全删全加)
bpLessonRepository.deleteList(lessons);
bpChapterRepository.deleteList(chapters);
bpFileRepository.deleteList(files);
line = bpLessonRepository.deleteList(lessons);
line = bpChapterRepository.deleteList(chapters);
line = bpFileRepository.deleteList(files);
bpLessonRepository.insertList(lessons);
bpChapterRepository.insertList(chapters);
bpFileRepository.insertList(files);
line = bpLessonRepository.insertList(lessons);
line = bpChapterRepository.insertList(chapters);
line = 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