修复课程资源删除bug

beetlsql3-dev
Mlxa0324 2 years ago
parent 39b97d8b5b
commit 837efb7910

@ -1,12 +1,10 @@
package com.ibeetl.admin.core.service; package com.ibeetl.admin.core.service;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.ibeetl.admin.core.dao.CoreDictDao; import com.ibeetl.admin.core.dao.CoreDictDao;
import com.ibeetl.admin.core.entity.CoreDict; import com.ibeetl.admin.core.entity.CoreDict;
import com.ibeetl.admin.core.util.BeetlSqlKit; import com.ibeetl.admin.core.util.BeetlSqlKit;
import com.ibeetl.admin.core.util.enums.DelFlagEnum; import com.ibeetl.admin.core.util.enums.DelFlagEnum;
import com.ibeetl.starter.ObjectMapperJsonUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -15,7 +13,6 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -101,7 +98,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
} }
} }
@Cacheable(value = "core.coreDict:.findCoreDictByTable", key="#type+\"_\"+#value") @Cacheable(value = "core.coreDict.findCoreDictByTable", key="#type+\"_\"+#value")
public CoreDict findCoreDictByTable(String type,String value) { public CoreDict findCoreDictByTable(String type,String value) {
List<CoreDict> list = findAllByTable(type); List<CoreDict> list = findAllByTable(type);
if(list==null) { if(list==null) {
@ -123,7 +120,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
* @param value * @param value
* @return * @return
*/ */
@Cacheable(value = "core.coreDict:.findCoreDictByTableAndField", key="#type+\"_\"+#value") @Cacheable(value = "core.coreDict.findCoreDictByTableAndField", key="#type+\"_\"+#value")
public List<CoreDict> findCoreDictByTableAndField(String type, Object value) { public List<CoreDict> findCoreDictByTableAndField(String type, Object value) {
return findAllByTable(BeetlSqlKit.render(type, value)); return findAllByTable(BeetlSqlKit.render(type, value));
} }

@ -2,6 +2,7 @@ package com.ibeetl.jlw.dao;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeCourseInfo; import com.ibeetl.jlw.entity.TeacherOpenCourseMergeCourseInfo;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeCourseInfoMyTree;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeCourseInfoTree; import com.ibeetl.jlw.entity.TeacherOpenCourseMergeCourseInfoTree;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeCourseInfoQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeCourseInfoQuery;
import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.core.engine.PageQuery;
@ -62,6 +63,15 @@ public interface TeacherOpenCourseMergeCourseInfoDao extends BaseMapper<TeacherO
* @return * @return
*/ */
TeacherOpenCourseMergeCourseInfoTree getTreeLocalCacheByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId); TeacherOpenCourseMergeCourseInfoTree getTreeLocalCacheByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId);
/**
* ID
*
*
* @param teacherOpenCourseId
* @return
*/
List<TeacherOpenCourseMergeCourseInfoMyTree> getByOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId);
/** /**
* ID * ID
* *

@ -356,6 +356,7 @@ public class TeacherOpenCourseMergeCourseInfo extends BaseEntity implements Comp
return (List<TeacherOpenCourseMergeCourseInfo>)this.get("children"); return (List<TeacherOpenCourseMergeCourseInfo>)this.get("children");
} }
@Override @Override
public int compareTo(TeacherOpenCourseMergeCourseInfo o) { public int compareTo(TeacherOpenCourseMergeCourseInfo o) {
return this.getTeacherOpenCourseMergeCourseInfoId().compareTo(o.getTeacherOpenCourseMergeCourseInfoId()); return this.getTeacherOpenCourseMergeCourseInfoId().compareTo(o.getTeacherOpenCourseMergeCourseInfoId());

@ -0,0 +1,136 @@
package com.ibeetl.jlw.entity;
import com.ibeetl.admin.core.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;
import org.beetl.sql.annotation.entity.AutoID;
import org.beetl.sql.annotation.entity.Table;
import org.beetl.sql.fetch.annotation.Fetch;
/**
* - -线
* Tree
*
* @author mlx
*/
@Data
@Fetch(level = 5)
@Table(name = "teacher_open_course_merge_course_info")
@EqualsAndHashCode(callSuper=false)
@FieldNameConstants
@SuppressWarnings("ALL")
public class TeacherOpenCourseMergeCourseInfoMyTree extends BaseEntity implements Comparable<TeacherOpenCourseMergeCourseInfo> {
//ID
@AutoID
private Long teacherOpenCourseMergeCourseInfoId ;
//开课ID
private Long teacherOpenCourseId ;
//名称(课程名 或 章名 或 节名)
private String courseInfoName ;
//课程缩略图
private String courseInfoThumbnail ;
// @Dict(type = "course_label.course_label_name.1-1")
//课程标签ID
private Long courseLabelId ;
// @UpdateIgnore
// @InsertIgnore
//// @FetchSql("select course_label_name from course_label " +
//// "where course_label_status = 1 " +
//// "and course_label_id = #courseLabelId# ")
// private String courseLabelIdText;
//课程学习人数基数
private Integer courseInfoBasicsCount ;
//课程简介
private String courseInfoContent ;
//状态(1启用 2禁用 3删除)
private Integer courseInfoStatus ;
//类型(1课程 2章 3节)
private Integer courseInfoType ;
//父节点ID
private Long courseInfoParentId ;
//视频ID(resources_info_id和节对应)
private Long courseVideoId ;
//课件ID(resources_info_id和节对应)
private Long courseCoursewareId ;
//附件IDs(resources_info_id和节对应)
private String courseEnclosureIds ;
//客观题IDs和章对应
private String resourcesQuestionIds ;
//竞赛题IDs和章对应
private String resourcesCompetitionIds ;
//实训题IDs和章对应
private String resourcesTrainingIds ;
//组织机构ID
private Long orgId ;
//后台用户ID
private Long userId ;
//// @FetchSql("select * from teacher_open_course_merge_course_info t " +
//// "where t.course_info_parent_id = #teacherOpenCourseMergeCourseInfoId# ")
// @UpdateIgnore
// @InsertIgnore
// private List<TeacherOpenCourseMergeCourseInfoMyTree> children;
//
//// @FetchSql("select count(1) > 0 from teacher_open_course_merge_course_info t " +
//// "where t.course_info_parent_id = #teacherOpenCourseMergeCourseInfoId# ")
// @UpdateIgnore
// @InsertIgnore
// private Boolean hasChildren;
// @UpdateIgnore
// @InsertIgnore
// @FetchSql("SELECT * FROM " +
// "teacher_open_course_merge_resources_info t " +
// "WHERE 1 = 1 " +
// "AND teacher_open_course_id = #teacherOpenCourseId# " +
// "and t.teacher_open_course_merge_course_info_id = #teacherOpenCourseMergeCourseInfoId# ")
// private List<TeacherOpenCourseMergeResourcesInfo> resourcesInfo;
@Override
public int compareTo(TeacherOpenCourseMergeCourseInfo o) {
// String o1Str = ReUtil.get("\\d+", o.getCourseInfoName(), 0);
// String o2Str = ReUtil.get("\\d+", this.getCourseInfoName(), 0);
//
// int o1num = NumberUtil.isNumber(o1Str) ? Integer.valueOf(o1Str) : -1;
// int o2num = NumberUtil.isNumber(o2Str) ? Integer.valueOf(o2Str) : -1;
// return o1num - o2num;
return this.getTeacherOpenCourseMergeCourseInfoId().compareTo(o.getTeacherOpenCourseMergeCourseInfoId());
}
}

@ -1,5 +1,6 @@
package com.ibeetl.jlw.entity; package com.ibeetl.jlw.entity;
import cn.hutool.core.util.ObjectUtil;
import com.ibeetl.admin.core.entity.BaseEntity; import com.ibeetl.admin.core.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -32,13 +33,6 @@ public class TeacherOpenCourseMergeCourseInfoTree extends BaseEntity {
//开课ID //开课ID
private Long teacherOpenCourseId ; private Long teacherOpenCourseId ;
@UpdateIgnore
@InsertIgnore
@FetchSql("select teacher_open_course_title from teacher_open_course " +
"where teacher_open_course_status = 1 " +
"and teacher_open_course_id = #teacherOpenCourseId# ")
private String teacherOpenCourseIdText;
//名称(课程名 或 章名 或 节名) //名称(课程名 或 章名 或 节名)
private String courseInfoName ; private String courseInfoName ;
@ -50,22 +44,6 @@ public class TeacherOpenCourseMergeCourseInfoTree extends BaseEntity {
//课程标签ID //课程标签ID
private Long courseLabelId ; private Long courseLabelId ;
@UpdateIgnore
@InsertIgnore
@FetchSql("select course_label_name from course_label " +
"where course_label_status = 1 " +
"and course_label_id = #courseLabelId# ")
private String courseLabelIdText;
@UpdateIgnore
@InsertIgnore
@FetchSql("SELECT * FROM " +
"teacher_open_course_merge_resources_info t " +
"WHERE 1 = 1 " +
"AND teacher_open_course_id = #teacherOpenCourseId# " +
"and t.teacher_open_course_merge_course_info_id = #teacherOpenCourseMergeCourseInfoId# ")
private List<TeacherOpenCourseMergeResourcesInfo> resourcesInfo;
//课程学习人数基数 //课程学习人数基数
private Integer courseInfoBasicsCount ; private Integer courseInfoBasicsCount ;
@ -118,16 +96,27 @@ public class TeacherOpenCourseMergeCourseInfoTree extends BaseEntity {
private Long userId ; private Long userId ;
@FetchSql("select * from teacher_open_course_merge_course_info t " +
"where t.course_info_parent_id = #teacherOpenCourseMergeCourseInfoId# ")
@UpdateIgnore @UpdateIgnore
@InsertIgnore @InsertIgnore
private List<TeacherOpenCourseMergeCourseInfoTree> children; private Boolean hasChildren;
@FetchSql("select count(1) > 0 from teacher_open_course_merge_course_info t " +
"where t.course_info_parent_id = #teacherOpenCourseMergeCourseInfoId# ")
@UpdateIgnore @UpdateIgnore
@InsertIgnore @InsertIgnore
private Boolean hasChildren; @FetchSql("SELECT * FROM " +
"teacher_open_course_merge_resources_info t " +
"WHERE 1 = 1 " +
"AND teacher_open_course_id = #teacherOpenCourseId# " +
"and t.teacher_open_course_merge_course_info_id = #teacherOpenCourseMergeCourseInfoId# ")
private List<TeacherOpenCourseMergeResourcesInfo> resourcesInfo;
@FetchSql("select * from teacher_open_course_merge_course_info t " +
"where t.course_info_parent_id = #teacherOpenCourseMergeCourseInfoId# and t.course_info_status = 1 ")
@UpdateIgnore
@InsertIgnore
private List<TeacherOpenCourseMergeCourseInfoTree> children;
public void setChildren(List<TeacherOpenCourseMergeCourseInfoTree> children) {
this.children = children;
setHasChildren(ObjectUtil.isNotEmpty(children));
}
} }

@ -5,6 +5,9 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
@ -12,12 +15,8 @@ import cn.jlw.util.ToolUtils;
import cn.jlw.validate.ValidateConfig; import cn.jlw.validate.ValidateConfig;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Optional;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.ibeetl.admin.core.entity.CoreUser; import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreBaseService; import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.CacheUtils;
import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode; import com.ibeetl.admin.core.web.JsonReturnCode;
@ -25,7 +24,7 @@ import com.ibeetl.jlw.dao.TeacherOpenCourseMergeCourseInfoDao;
import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO; import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeCourseInfoQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeCourseInfoQuery;
import lombok.SneakyThrows; import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeResourcesInfoQuery;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -37,7 +36,6 @@ import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -47,15 +45,16 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.*; import java.io.*;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import static cn.hutool.core.util.ArrayUtil.join; import static cn.hutool.core.util.ArrayUtil.join;
import static cn.hutool.core.util.ObjectUtil.defaultIfNull; import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue; import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue;
import static com.ibeetl.jlw.enums.CopyFromEnum.FROM_OPEN_COURSE; import static com.ibeetl.jlw.enums.CopyFromEnum.FROM_OPEN_COURSE;
import static com.ibeetl.jlw.enums.GlobalUpStatusEnum.UP;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
/** /**
@ -104,14 +103,14 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
/** /**
* {@link #getTreeLocalCacheByTeacherOpenCourseId} * {@link #getTreeLocalCacheByTeacherOpenCourseId}
*/ */
private final LoadingCache<Long, Optional<TeacherOpenCourseMergeCourseInfoTree>> treeLocalCache // private final LoadingCache<Long, Optional<TeacherOpenCourseMergeCourseInfoTree>> treeLocalCache
= CacheUtils.buildAsyncReloadingCache(Duration.ofHours(1L), // 过期时间 1 小时 // = CacheUtils.buildAsyncReloadingCache(Duration.ofHours(1L), // 过期时间 1 小时
new CacheLoader<Long, Optional<TeacherOpenCourseMergeCourseInfoTree>>() { // new CacheLoader<Long, Optional<TeacherOpenCourseMergeCourseInfoTree>>() {
@Override // @Override
public Optional<TeacherOpenCourseMergeCourseInfoTree> load(Long teacherOpenCourseId) { // public Optional<TeacherOpenCourseMergeCourseInfoTree> load(Long teacherOpenCourseId) {
return Optional.fromNullable(teacherOpenCourseMergeCourseInfoDao.getTreeLocalCacheByTeacherOpenCourseId(teacherOpenCourseId)); // return Optional.fromNullable(teacherOpenCourseMergeCourseInfoDao.getTreeLocalCacheByTeacherOpenCourseId(teacherOpenCourseId));
} // }
}); // });
public PageQuery<TeacherOpenCourseMergeCourseInfo>queryByCondition(PageQuery query){ public PageQuery<TeacherOpenCourseMergeCourseInfo>queryByCondition(PageQuery query){
PageQuery ret = teacherOpenCourseMergeCourseInfoDao.queryByCondition(query); PageQuery ret = teacherOpenCourseMergeCourseInfoDao.queryByCondition(query);
@ -131,20 +130,20 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
* *
* @param key * @param key
*/ */
@SneakyThrows // @SneakyThrows
@Async // @Async
public void invalidateCourseInfoTreeLocalCache(Long key) { // public void invalidateCourseInfoTreeLocalCache(Long key) {
if(ObjectUtil.isEmpty(key)) { return; } // if(ObjectUtil.isEmpty(key)) { return; }
treeLocalCache.refresh(key); // treeLocalCache.refresh(key);
} // }
/** // /**
* // * 清理刷新缓存
*/ // */
@SneakyThrows // @SneakyThrows
@Async // @Async
public void invalidateAllCleanUpCourseInfoTreeLocalCache() { // public void invalidateAllCleanUpCourseInfoTreeLocalCache() {
treeLocalCache.invalidateAll(); // treeLocalCache.invalidateAll();
} // }
public void deleteByList(List list){ public void deleteByList(List list){
String ids = ""; String ids = "";
@ -155,7 +154,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
if(StringUtils.isNotBlank(ids)){ if(StringUtils.isNotBlank(ids)){
teacherOpenCourseMergeCourseInfoDao.deleteTeacherOpenCourseMergeCourseInfoByIds(ids); teacherOpenCourseMergeCourseInfoDao.deleteTeacherOpenCourseMergeCourseInfoByIds(ids);
teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache(); // teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache();
} }
} }
@ -177,7 +176,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
} }
} }
teacherOpenCourseMergeCourseInfoDao.deleteTeacherOpenCourseMergeCourseInfoByIds(ids); teacherOpenCourseMergeCourseInfoDao.deleteTeacherOpenCourseMergeCourseInfoByIds(ids);
teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache(); // teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache();
} catch (Exception e) { } catch (Exception e) {
throw new PlatformException("批量删除开课课程拉取失败", e); throw new PlatformException("批量删除开课课程拉取失败", e);
} }
@ -203,9 +202,9 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
insertBatch(teacherOpenCourseMergeCourseInfoList); insertBatch(teacherOpenCourseMergeCourseInfoList);
// 循环刷新缓存 // 循环刷新缓存
for (TeacherOpenCourseMergeCourseInfo openCourseMergeCourseInfo : teacherOpenCourseMergeCourseInfoList) { // for (TeacherOpenCourseMergeCourseInfo openCourseMergeCourseInfo : teacherOpenCourseMergeCourseInfoList) {
teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(openCourseMergeCourseInfo.getTeacherOpenCourseId()); // teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(openCourseMergeCourseInfo.getTeacherOpenCourseId());
} // }
} }
return msg; return msg;
} }
@ -222,7 +221,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
teacherOpenCourseMergeCourseInfo.setCourseInfoStatus(1); teacherOpenCourseMergeCourseInfo.setCourseInfoStatus(1);
teacherOpenCourseMergeCourseInfoDao.insert(teacherOpenCourseMergeCourseInfo); teacherOpenCourseMergeCourseInfoDao.insert(teacherOpenCourseMergeCourseInfo);
teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseId()); // teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseId());
teacherOpenCourseMergeCourseInfoQuery.setTeacherOpenCourseMergeCourseInfoId(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseMergeCourseInfoId()); teacherOpenCourseMergeCourseInfoQuery.setTeacherOpenCourseMergeCourseInfoId(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseMergeCourseInfoId());
JsonResult jsonResult = new JsonResult(); JsonResult jsonResult = new JsonResult();
jsonResult.setData(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseMergeCourseInfoId());//自增的ID丢进去 jsonResult.setData(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseMergeCourseInfoId());//自增的ID丢进去
@ -262,7 +261,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
String msg = ""; String msg = "";
TeacherOpenCourseMergeCourseInfo teacherOpenCourseMergeCourseInfo = teacherOpenCourseMergeCourseInfoQuery.pojo(); TeacherOpenCourseMergeCourseInfo teacherOpenCourseMergeCourseInfo = teacherOpenCourseMergeCourseInfoQuery.pojo();
teacherOpenCourseMergeCourseInfoDao.updateTemplateById(teacherOpenCourseMergeCourseInfo); teacherOpenCourseMergeCourseInfoDao.updateTemplateById(teacherOpenCourseMergeCourseInfo);
teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseId()); // teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeCourseInfo.getTeacherOpenCourseId());
return msg; return msg;
} }
@ -814,7 +813,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
// 调用子类实现 // 调用子类实现
beansOfType.forEach((beanName, bean) -> bean.resetOperationByTeacherOpenCourseId(teacherOpenCourseId)); beansOfType.forEach((beanName, bean) -> bean.resetOperationByTeacherOpenCourseId(teacherOpenCourseId));
// 清理缓存 // 清理缓存
invalidateAllCleanUpCourseInfoTreeLocalCache(); // invalidateAllCleanUpCourseInfoTreeLocalCache();
} }
@ -867,7 +866,8 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
*/ */
public TeacherOpenCourseMergeCourseInfoTree getTreeLocalCacheByTeacherOpenCourseId( public TeacherOpenCourseMergeCourseInfoTree getTreeLocalCacheByTeacherOpenCourseId(
@NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId) { @NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId) {
TeacherOpenCourseMergeCourseInfoTree teacherOpenCourseMergeCourseInfoTree = treeLocalCache.getUnchecked(teacherOpenCourseId).orNull(); TeacherOpenCourseMergeCourseInfoTree teacherOpenCourseMergeCourseInfoTree =
teacherOpenCourseMergeCourseInfoDao.getTreeLocalCacheByTeacherOpenCourseId(teacherOpenCourseId);
dictParser(teacherOpenCourseMergeCourseInfoTree); dictParser(teacherOpenCourseMergeCourseInfoTree);
return teacherOpenCourseMergeCourseInfoTree; return teacherOpenCourseMergeCourseInfoTree;
} }
@ -879,7 +879,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
* @param teacherOpenCourseId * @param teacherOpenCourseId
* @return * @return
*/ */
public TeacherOpenCourseMergeCourseInfo getTreeByTeacherOpenCourseId( public TeacherOpenCourseMergeCourseInfo getTreeByTeacherOpenCourseId1(
@NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId) { @NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId) {
TeacherOpenCourseMergeCourseInfo treeCacheByTeacherOpenCourseId = TeacherOpenCourseMergeCourseInfo treeCacheByTeacherOpenCourseId =
teacherOpenCourseMergeCourseInfoDao.getValueByTeacherOpenCourseId(teacherOpenCourseId); teacherOpenCourseMergeCourseInfoDao.getValueByTeacherOpenCourseId(teacherOpenCourseId);
@ -891,6 +891,60 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
return getTreeById(treeCacheByTeacherOpenCourseId.getTeacherOpenCourseMergeCourseInfoId()); return getTreeById(treeCacheByTeacherOpenCourseId.getTeacherOpenCourseMergeCourseInfoId());
} }
/**
* ID
*
*
* @param teacherOpenCourseId
* @return
*/
public Tree<String> getTreeByTeacherOpenCourseId(
@NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId) {
List<TeacherOpenCourseMergeCourseInfoMyTree> courseInfoList = teacherOpenCourseMergeCourseInfoDao
.getByOpenCourseId(teacherOpenCourseId);
dictParser(courseInfoList);
TeacherOpenCourseMergeResourcesInfoQuery resourcesInfoQuery = new TeacherOpenCourseMergeResourcesInfoQuery();
resourcesInfoQuery.setResourcesInfoStatus(UP);
resourcesInfoQuery.setTeacherOpenCourseId(teacherOpenCourseId);
final List<TeacherOpenCourseMergeResourcesInfo> resourcesInfoList = teacherOpenCourseMergeResourcesInfoService.getValuesByQueryNotWithPermission(resourcesInfoQuery);
CopyOnWriteArrayList<TeacherOpenCourseMergeResourcesInfo> resourcesInfoCopyOnWriteArrayList = new CopyOnWriteArrayList<>(resourcesInfoList);
TreeNodeConfig defaultConfig = new TreeNodeConfig();
defaultConfig.setIdKey(TeacherOpenCourseMergeCourseInfoMyTree.Fields.teacherOpenCourseMergeCourseInfoId);
defaultConfig.setParentIdKey(TeacherOpenCourseMergeCourseInfoMyTree.Fields.courseInfoParentId);
defaultConfig.setNameKey(TeacherOpenCourseMergeCourseInfoMyTree.Fields.courseInfoName);
defaultConfig.setWeightKey(TeacherOpenCourseMergeCourseInfoMyTree.Fields.teacherOpenCourseMergeCourseInfoId);
//3.转为树结构,其中rootId参数代表根节点的父级id值
List<Tree<String>> build = TreeUtil.build(courseInfoList, "0", defaultConfig, ((courseInfo, treeNode) -> {
Long courseInfoId = courseInfo.getTeacherOpenCourseMergeCourseInfoId();
List<TeacherOpenCourseMergeResourcesInfo> filteredResourcesInfoList = resourcesInfoCopyOnWriteArrayList.stream()
.filter(it -> it.getTeacherOpenCourseMergeCourseInfoId().equals(courseInfoId)).collect(Collectors.toList());
// 获取课程ids
String courseInfoIds = filteredResourcesInfoList.stream().map(TeacherOpenCourseMergeResourcesInfo::getTeacherOpenCourseMergeCourseInfoId)
.map(Objects::toString)
.collect(Collectors.joining(","));
// 删除临时变量
resourcesInfoCopyOnWriteArrayList.removeIf(it -> courseInfoIds.contains(it.getTeacherOpenCourseMergeCourseInfoId().toString()));
//对key进行映射赋值
treeNode.setId(courseInfoId.toString());
treeNode.setParentId(courseInfo.getCourseInfoParentId().toString());
treeNode.setName(courseInfo.getCourseInfoName());
treeNode.putExtra("courseInfoType", courseInfo.getCourseInfoType());
treeNode.putExtra("courseInfoContent", courseInfo.getCourseInfoContent());
treeNode.putExtra("resourcesInfo", filteredResourcesInfoList);
}));
if (build == null) { return null; }
return build.get(0);
}
/** /**
* IDID * IDID

@ -133,7 +133,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
jsonResult.setMsg(msg); jsonResult.setMsg(msg);
// 刷新缓存 // 刷新缓存
teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeCourseInfoId()); // teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeCourseInfoId());
return jsonResult; return jsonResult;
} }
@ -143,7 +143,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
teacherOpenCourseMergeResourcesInfoDao.updateTemplateById(teacherOpenCourseMergeResourcesInfo); teacherOpenCourseMergeResourcesInfoDao.updateTemplateById(teacherOpenCourseMergeResourcesInfo);
// 刷新缓存 // 刷新缓存
teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeCourseInfoId()); // teacherOpenCourseMergeCourseInfoService.invalidateCourseInfoTreeLocalCache(teacherOpenCourseMergeResourcesInfo.getTeacherOpenCourseMergeCourseInfoId());
return msg; return msg;
} }

@ -99,7 +99,7 @@ public class TeacherOpenCourseService extends CoreBaseService<TeacherOpenCourse>
beansOfType.forEach(stringDeleteResourcesByBiConsumer); beansOfType.forEach(stringDeleteResourcesByBiConsumer);
} }
// 清理缓存 // 清理缓存
teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache(); // teacherOpenCourseMergeCourseInfoService.invalidateAllCleanUpCourseInfoTreeLocalCache();
} catch (Exception e) { } catch (Exception e) {
throw new PlatformException("批量删除TeacherOpenCourse失败", e); throw new PlatformException("批量删除TeacherOpenCourse失败", e);
} }

@ -517,7 +517,7 @@ public class TeacherOpenCourseMergeCourseInfoController{
/** /**
* *
* * BUG
* *
* @param teacherOpenCourseId ID * @param teacherOpenCourseId ID
* @return * @return

@ -899,4 +899,32 @@ getTreeLocalCacheByTeacherOpenCourseId
and t.teacher_open_course_id = #teacherOpenCourseId# and t.teacher_open_course_id = #teacherOpenCourseId#
and t.course_info_status = 1 and t.course_info_status = 1
and t.course_info_type = 1 and t.course_info_type = 1
limit 1 limit 1
getByOpenCourseId
===
* 根据开课ID查询关联的课程章节小节ID
select
teacher_open_course_merge_course_info_id,
teacher_open_course_id,
course_info_name,
course_info_thumbnail,
course_label_id,
course_info_basics_count,
course_info_content,
course_info_status,
course_info_type,
ifnull(t.course_info_parent_id, 0) as course_info_parent_id,
course_video_id,
course_courseware_id,
course_enclosure_ids,
resources_question_ids,
resources_competition_ids,
resources_training_ids,
org_id,
user_id
from teacher_open_course_merge_course_info t
where 1 = 1
and t.teacher_open_course_id = #teacherOpenCourseId#
and t.course_info_status = 1
Loading…
Cancel
Save