mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 18:36:51 +08:00
Compare commits
4 Commits
20250916-f
...
20251030-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20e3b001d5 | ||
|
|
a37f90aeaa | ||
|
|
e767345c1e | ||
|
|
6fe6f7c6e5 |
@@ -358,8 +358,10 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
//修改在线课开课状态=已开课
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
CourseParam param = new CourseParam();
|
||||
param.setId(courseId);
|
||||
thirdApi.updateOnLineStatua(param,token);
|
||||
param.setId(c.getId());
|
||||
param.setOrgId(c.getOrgId());
|
||||
param.setOrgName(c.getOrgName());
|
||||
thirdApi.updateOrSaveCourse(param,token);
|
||||
}
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class CourseTeacherDao extends BaseDao<CourseTeacher> {
|
||||
|
||||
//List<CourseTeacher>
|
||||
|
||||
public List<CourseTeacher> findByCourseId(String courseId) {
|
||||
try {
|
||||
return sqlFindList("SELECT * FROM boe_course_teacher WHERE course_id = ?1", courseId);
|
||||
} catch (Exception e) {
|
||||
log.warn("查询课程教师列表失败", e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
//List<CourseTeacher>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseTeacherDeletedRecord;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CourseTeacherDeletedRecordDao extends BaseDao<CourseTeacherDeletedRecord> {
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.xboe.module.course.dao;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.entity.CourseTeacherModifyRecord;
|
||||
import com.xboe.module.course.util.RequestIdUtil;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author guo jia
|
||||
*/
|
||||
@Repository
|
||||
public class CourseTeacherModifyRecordDao extends BaseDao<CourseTeacherModifyRecord> {
|
||||
|
||||
public void insertRecord(String type, String location, CourseTeacher courseTeacher, String body) {
|
||||
CourseTeacherModifyRecord entity = new CourseTeacherModifyRecord();
|
||||
entity.setRequestId(RequestIdUtil.getCurrentRequestId());
|
||||
entity.setType(type);
|
||||
entity.setLocation(location);
|
||||
entity.setTeacherId(courseTeacher.getTeacherId());
|
||||
entity.setTeacherName(courseTeacher.getTeacherName());
|
||||
entity.setCourseId(courseTeacher.getCourseId());
|
||||
entity.setBody(body);
|
||||
entity.setDeleted(0);
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
save(entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 课程任课教师删除记录
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "course_teacher_deleted_record")
|
||||
public class CourseTeacherDeletedRecord extends IdBaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 课程id
|
||||
*/
|
||||
@Column(name = "course_id", nullable = false, length = 20)
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 教师id,实际上就是aid
|
||||
*
|
||||
*/
|
||||
@Column(name = "teacher_id", nullable = false, length = 20)
|
||||
private String teacherId;
|
||||
|
||||
/**
|
||||
* 教师姓名
|
||||
*
|
||||
*/
|
||||
@Column(name = "teacher_name", length = 30)
|
||||
private String teacherName;
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 讲师操作记录表
|
||||
* 为了监控PngCode-SZX-1241问题临时创建的表
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "course_teacher_modify_record")
|
||||
public class CourseTeacherModifyRecord {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 请求ID
|
||||
* 同一个请求ID表示删除操作是在一次请求中完成的
|
||||
*/
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
* INSERT、UPDATE、DELETE
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 讲师账号ID
|
||||
*/
|
||||
private String teacherId;
|
||||
|
||||
/**
|
||||
* 讲师姓名
|
||||
*/
|
||||
private String teacherName;
|
||||
|
||||
/**
|
||||
* 在线课ID
|
||||
*/
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 请求体
|
||||
*/
|
||||
private String body;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createId;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateId;
|
||||
}
|
||||
@@ -1,6 +1,41 @@
|
||||
package com.xboe.module.course.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.management.Query;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.TempFilterConfig;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
@@ -9,39 +44,16 @@ import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.dto.RankingDto;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.interaction.service.ICourseGradeService;
|
||||
import com.xboe.system.authority.service.IResDataManagerService;
|
||||
import com.xboe.system.logs.dao.SysLogAuditDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -102,8 +114,8 @@ public class CourseServiceImpl implements ICourseService {
|
||||
RestHighLevelClient restHighLevelClient;
|
||||
|
||||
@Resource
|
||||
private CourseTeacherModifyRecordDao courseTeacherModifyRecordDao;
|
||||
|
||||
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
|
||||
|
||||
/**
|
||||
* 生成过滤条件
|
||||
*
|
||||
@@ -160,7 +172,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
filters.add(FieldFilters.in("device", Course.DEVICE_MOBILE, Course.DEVICE_ALL));
|
||||
} else if (dto.getDevice() == Course.DEVICE_ALL) {
|
||||
filters.add(FieldFilters.eq("device", Course.DEVICE_ALL));
|
||||
}else if (dto.getDevice() == Course.DEVICE_INTERNAL) {
|
||||
} else if (dto.getDevice() == Course.DEVICE_INTERNAL) {
|
||||
filters.add(FieldFilters.eq("device", Course.DEVICE_INTERNAL));
|
||||
}
|
||||
|
||||
@@ -258,13 +270,13 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//// Set<String>list=new HashSet<>();
|
||||
//// if(s!=null&&!s.isEmpty()){
|
||||
//// list=Arrays.stream(s.split(",")).collect(Collectors.toSet());
|
||||
//// }else {
|
||||
//// }else {
|
||||
//// Set<String> ss = getSeache(dto);
|
||||
//// String courseSearch=String.join(",",ss);
|
||||
//// redisTemplate.opsForValue().set("course_search",courseSearch);
|
||||
//// //设置过期时间为1分钟
|
||||
//// redisTemplate.expire("course_search", 1, TimeUnit.MINUTES);
|
||||
//// }
|
||||
//// }
|
||||
// Set<String> list = getSeache(dto);
|
||||
// //有权限的查询,也同时查询出创建人的数据,在权限上
|
||||
// if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
@@ -344,8 +356,9 @@ public class CourseServiceImpl implements ICourseService {
|
||||
// // 使用distinct()配合自定义的去重条件
|
||||
// .filter(distinctByKey(c -> c.getId()))
|
||||
// .collect(Collectors.toList());
|
||||
//// PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
//// long endTime = System.nanoTime();
|
||||
|
||||
/// / PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
/// / long endTime = System.nanoTime();
|
||||
// //log.info("查询出的条数:"+rs.getCount());
|
||||
// if(!mergedList.isEmpty()){
|
||||
// //去掉未发布的课程
|
||||
@@ -402,30 +415,30 @@ public class CourseServiceImpl implements ICourseService {
|
||||
if (TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
if (dto.getIsSystemAdmin() == null || !dto.getIsSystemAdmin()) {
|
||||
List<String> finalStrings = strings;
|
||||
log.info("dto为"+dto);
|
||||
if(dto.getIsCreateCourse()!=null&&dto.getIsCreateCourse()){
|
||||
log.info("dto为" + dto);
|
||||
if (dto.getIsCreateCourse() != null && dto.getIsCreateCourse()) {
|
||||
listByFilters2.removeIf(e -> {
|
||||
//去掉未发布的课程
|
||||
if (!e.getPublished() && seache.contains(e.getId()) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
return true;
|
||||
}
|
||||
//去掉所有条件都不符合的课程
|
||||
if(!seache.contains(e.getId())&&!dto.getReadIds().contains(e.getId())&& !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())){
|
||||
if (!seache.contains(e.getId()) && !dto.getReadIds().contains(e.getId()) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//将需要隐藏的做标记
|
||||
listByFilters2.forEach(e -> {
|
||||
if ((seache.contains(e.getId())||dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
if ((seache.contains(e.getId()) || dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
e.setIsPermission(false);
|
||||
} else {
|
||||
e.setIsPermission(true);
|
||||
}
|
||||
});
|
||||
listByFilters2.sort(Comparator.comparing(Course::getIsPermission).reversed());
|
||||
}else{
|
||||
List<Course> collect = listByFilters2.stream().filter(e ->dto.getReadIds().contains(e.getOrgId())||dto.getOrgAid().equals(e.getSysCreateAid())||finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
|
||||
} else {
|
||||
List<Course> collect = listByFilters2.stream().filter(e -> dto.getReadIds().contains(e.getOrgId()) || dto.getOrgAid().equals(e.getSysCreateAid()) || finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
|
||||
List<Course> paginate = paginate(collect, pageIndex, pageSize);
|
||||
PageList<Course> rs = new PageList<>();
|
||||
rs.setCount(collect.size());
|
||||
@@ -814,23 +827,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
@Override
|
||||
public void delete(String id, boolean erasable, String aid, String name, String remark) {
|
||||
// 增加操作boe_course_teacher表记录
|
||||
String body = "courseId=" + id + " aid=" + aid + " name=" + name + " remark=" + remark;
|
||||
String location = "/xboe/m/course/manage/delete";
|
||||
List<CourseTeacher> teacherList = courseTeacherDao.findByCourseId(id);
|
||||
String jsonStr = JSONUtil.toJsonStr(teacherList);
|
||||
log.info("teacherList:{}", jsonStr);
|
||||
try {
|
||||
List<List> list = JSONUtil.toList(jsonStr, List.class);
|
||||
list.forEach(item -> {
|
||||
for (Object teacher : item) {
|
||||
courseTeacherModifyRecordDao.insertRecord("DELETE", location, (CourseTeacher) teacher, body);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.warn("增加操作boe_course_teacher表记录失败", e);
|
||||
}
|
||||
|
||||
if (!erasable) {
|
||||
courseDao.setDeleted(id);
|
||||
courseDao.updateFieldById(id, "name", "已删除" + name);
|
||||
@@ -862,7 +858,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
}
|
||||
|
||||
// 删除ES数据
|
||||
deletedStudyResourceBatchByCourseIdAndType(id,c.getType());
|
||||
deletedStudyResourceBatchByCourseIdAndType(id, c.getType());
|
||||
} else {
|
||||
//彻底删除,课件设置为无课程状态
|
||||
courseDao.setDeleted(id);
|
||||
@@ -914,9 +910,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.save(ct);
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
courseTeacherModifyRecordDao.insertRecord("DELETE", "/xboe/m/course/manage/save", ct, JSONUtil.toJsonStr(full));
|
||||
}
|
||||
}
|
||||
if (full.getCrowds() != null && !full.getCrowds().isEmpty()) {
|
||||
@@ -999,29 +992,14 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
full.getCourse().setSysVersion(c.getSysVersion());
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
String body = null;
|
||||
String location = null;
|
||||
try {
|
||||
body = JSONUtil.toJsonStr(full);
|
||||
location = "/xboe/m/course/manage/save";
|
||||
List<CourseTeacher> teacherList = courseTeacherDao.findByCourseId(c.getId());
|
||||
for (CourseTeacher teacher : teacherList) {
|
||||
courseTeacherModifyRecordDao.insertRecord("DELETE", location, teacher, body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("增加操作boe_course_teacher表记录失败", e);
|
||||
}
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
courseTeacherModifyRecordDao.insertRecord("INSERT", location, ct, body);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1070,29 +1048,14 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
full.getCourse().setSysVersion(c.getSysVersion());
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
String body = null;
|
||||
String location = null;
|
||||
try {
|
||||
body = JSONUtil.toJsonStr(full);
|
||||
location = "/xboe/m/course/manage/submit";
|
||||
List<CourseTeacher> teacherList = courseTeacherDao.findByCourseId(c.getId());
|
||||
for (CourseTeacher teacher : teacherList) {
|
||||
courseTeacherModifyRecordDao.insertRecord("DELETE", location, teacher, body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("增加操作boe_course_teacher表记录失败", e);
|
||||
}
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
courseTeacherModifyRecordDao.insertRecord("INSERT", location, ct, body);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1122,29 +1085,14 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setPublishTime(LocalDateTime.now());
|
||||
courseDao.update(c);
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
String body = null;
|
||||
String location = null;
|
||||
try {
|
||||
body = "body=" + JSONUtil.toJsonStr(full) + " aid=[" + aid + "] aname=[" + aname + "] ";
|
||||
location = "/xboe/m/course/audit/submit-publish";
|
||||
List<CourseTeacher> teacherList = courseTeacherDao.findByCourseId(c.getId());
|
||||
for (CourseTeacher teacher : teacherList) {
|
||||
courseTeacherModifyRecordDao.insertRecord("DELETE", location, teacher, body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("增加操作boe_course_teacher表记录失败", e);
|
||||
}
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
|
||||
// 增加操作boe_course_teacher表记录
|
||||
courseTeacherModifyRecordDao.insertRecord("INSERT", location, ct, body);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -2061,4 +2009,25 @@ public class CourseServiceImpl implements ICourseService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除boe_course_teacher数据时把删除的数据储存到boe_course_teacher_deleted_record表
|
||||
* boe_course_teacher表没有deleted字段,兼容处理
|
||||
*
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
private void createCourseTeacherDeletedRecord(String courseId) {
|
||||
List<CourseTeacherDeletedRecord> courseTeacherList = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId)).stream().map(ct -> {
|
||||
CourseTeacherDeletedRecord courseTeacherDeletedRecord = new CourseTeacherDeletedRecord();
|
||||
courseTeacherDeletedRecord.setCourseId(ct.getCourseId());
|
||||
courseTeacherDeletedRecord.setTeacherId(ct.getTeacherId());
|
||||
courseTeacherDeletedRecord.setTeacherName(ct.getTeacherName());
|
||||
return courseTeacherDeletedRecord;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(courseTeacherList)) {
|
||||
courseTeacherDeletedRecordDao.saveList(courseTeacherList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.xboe.module.course.util;
|
||||
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* @author guo jia
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class RequestIdUtil {
|
||||
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
public static final String REQUEST_ID_KEY = "requestId";
|
||||
|
||||
public static String genRequestId() {
|
||||
byte[] bytes = new byte[8];
|
||||
RequestIdUtil.RANDOM.nextBytes(bytes);
|
||||
return HexUtil.encodeHexStr(bytes);
|
||||
}
|
||||
|
||||
public static void genAndSetRequestId() {
|
||||
setRequestId(genRequestId());
|
||||
}
|
||||
|
||||
public static void setRequestId(String requestId) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attributes != null) {
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
request.setAttribute(REQUEST_ID_KEY, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCurrentRequestId() {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
String requestId = null;
|
||||
if (attributes != null) {
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
requestId = (String) request.getAttribute(REQUEST_ID_KEY);
|
||||
}
|
||||
return requestId;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user