mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-14 05:16:49 +08:00
案例查询增加一个接口
This commit is contained in:
@@ -52,6 +52,36 @@ public class CasesApi extends ApiBaseController {
|
|||||||
private CasesMajorTypeDao casesMajorTypeDao;
|
private CasesMajorTypeDao casesMajorTypeDao;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于后台管理
|
||||||
|
* @param pager
|
||||||
|
* @param caseVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/manage")
|
||||||
|
public JsonResponse<PageList<Cases>> manage(Pagination pager, CaseVo caseVo){
|
||||||
|
PageList<Cases> views = casesService.managerList(pager.getPageIndex(), pager.getPageSize(), caseVo);
|
||||||
|
if(views!=null){
|
||||||
|
if(views.getList()!=null && !views.getList().isEmpty()){
|
||||||
|
for (Cases c:views.getList()) {
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
List<CasesMajorType> caseId = casesMajorTypeDao.findList(FieldFilters.eq("caseId", c.getId()));
|
||||||
|
if(caseId!=null && !caseId.isEmpty()){
|
||||||
|
for (CasesMajorType cm:caseId) {
|
||||||
|
stringBuffer.append(cm.getMajorId());
|
||||||
|
stringBuffer.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(stringBuffer.length()>0){
|
||||||
|
stringBuffer.deleteCharAt(stringBuffer.length()-1);
|
||||||
|
c.setMajorType(stringBuffer.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success(views);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 案例分页搜索查询 orders 状态 1代表时间最近,2代表热度最高
|
* 案例分页搜索查询 orders 状态 1代表时间最近,2代表热度最高
|
||||||
|
|||||||
@@ -279,12 +279,12 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
if(StringUtils.isBlank(dto.getCourse().getOrgId())) {
|
if(StringUtils.isBlank(dto.getCourse().getOrgId())) {
|
||||||
return badRequest("请选择资源归属");
|
return badRequest("请选择资源归属");
|
||||||
}
|
}
|
||||||
|
CurrentUser cuser=getCurrent();
|
||||||
dto.getCourse().setStatus(Course.STATUS_AUDIT_FINISH);//设置为审核通过状态
|
dto.getCourse().setStatus(Course.STATUS_AUDIT_FINISH);//设置为审核通过状态
|
||||||
dto.getCourse().setEnabled(true);//设置启用状态问题
|
dto.getCourse().setEnabled(true);//设置启用状态问题
|
||||||
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
|
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
|
||||||
try {
|
try {
|
||||||
courseService.submitAndPublish(dto);
|
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
|
||||||
return success(true);
|
return success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("默认管理员提交直接发布处理失败",e);
|
log.error("默认管理员提交直接发布处理失败",e);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package com.xboe.module.course.dao;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.xboe.core.orm.BaseDao;
|
import com.xboe.core.orm.BaseDao;
|
||||||
import com.xboe.module.course.entity.CourseAudit;
|
import com.xboe.module.course.entity.CourseAuditRecord;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class CourseAuditRecordDao extends BaseDao<CourseAudit>{
|
public class CourseAuditRecordDao extends BaseDao<CourseAuditRecord>{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ public class CourseAuditRecord extends IdBaseEntity{
|
|||||||
@Column(name = "course_id",nullable=false, length=20)
|
@Column(name = "course_id",nullable=false, length=20)
|
||||||
private String courseId;
|
private String courseId;
|
||||||
|
|
||||||
|
@Column(name = "course_name",nullable=false, length=100)
|
||||||
|
private String courseName;
|
||||||
|
|
||||||
/**审核人id*/
|
/**审核人id*/
|
||||||
@Column(name = "aid",nullable=false, length=20)
|
@Column(name = "aid",nullable=false, length=20)
|
||||||
private String aid;
|
private String aid;
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ package com.xboe.module.course.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
import com.xboe.module.course.dto.CourseQueryDto;
|
||||||
import com.xboe.module.course.entity.Course;
|
|
||||||
import com.xboe.module.course.entity.CourseAudit;
|
import com.xboe.module.course.entity.CourseAudit;
|
||||||
import com.xboe.system.logs.entity.SysLogAudit;
|
import com.xboe.module.course.entity.CourseAuditRecord;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +62,22 @@ public interface ICourseAuditService {
|
|||||||
// List<SysLogAudit> findLogs(String courseId,String teacherId);
|
// List<SysLogAudit> findLogs(String courseId,String teacherId);
|
||||||
|
|
||||||
//以下是新增加的公开课的审核
|
//以下是新增加的公开课的审核
|
||||||
|
/**
|
||||||
|
* 查询需要审核的课程
|
||||||
|
* @param pageIndex
|
||||||
|
* @param pageSize
|
||||||
|
* @param courseName
|
||||||
|
* @param auditState
|
||||||
|
* @param aid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageList<CourseAuditRecord> pageRecord(int pageIndex, int pageSize,String courseName,Integer auditState, String aid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交审核
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
void submitAudit(CourseAuditRecord record);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,9 +168,11 @@ public interface ICourseService {
|
|||||||
/**
|
/**
|
||||||
* 用于默认管理员,直接提交发布,不走审核流程
|
* 用于默认管理员,直接提交发布,不走审核流程
|
||||||
* @param full
|
* @param full
|
||||||
|
* @param aid 操作人id
|
||||||
|
* @param aname 姓名
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
void submitAndPublish(CourseFullDto full)throws Exception;
|
void submitAndPublish(CourseFullDto full,String aid,String aname)throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交一个课程
|
* 提交一个课程
|
||||||
|
|||||||
@@ -6,22 +6,30 @@ import javax.annotation.Resource;
|
|||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
|
import com.xboe.core.event.IEventDataSender;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
import com.xboe.core.orm.UpdateBuilder;
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.module.course.dao.CourseAuditDao;
|
import com.xboe.module.course.dao.CourseAuditDao;
|
||||||
import com.xboe.module.course.dao.CourseAuditRecordDao;
|
import com.xboe.module.course.dao.CourseAuditRecordDao;
|
||||||
import com.xboe.module.course.dao.CourseDao;
|
import com.xboe.module.course.dao.CourseDao;
|
||||||
import com.xboe.module.course.dao.CourseHRBPAuditDao;
|
import com.xboe.module.course.dao.CourseHRBPAuditDao;
|
||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||||
import com.xboe.module.course.entity.Course;
|
import com.xboe.module.course.entity.Course;
|
||||||
import com.xboe.module.course.entity.CourseAudit;
|
import com.xboe.module.course.entity.CourseAudit;
|
||||||
|
import com.xboe.module.course.entity.CourseAuditRecord;
|
||||||
import com.xboe.module.course.entity.CourseHRBPAudit;
|
import com.xboe.module.course.entity.CourseHRBPAudit;
|
||||||
|
import com.xboe.module.course.entity.CourseTeacher;
|
||||||
import com.xboe.module.course.service.ICourseAuditService;
|
import com.xboe.module.course.service.ICourseAuditService;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CourseAuditServiceImpl implements ICourseAuditService{
|
public class CourseAuditServiceImpl implements ICourseAuditService{
|
||||||
|
|
||||||
@@ -34,8 +42,17 @@ public class CourseAuditServiceImpl implements ICourseAuditService{
|
|||||||
@Resource
|
@Resource
|
||||||
CourseHRBPAuditDao courseHRBPAuditDao;
|
CourseHRBPAuditDao courseHRBPAuditDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CourseTeacherDao courseTeacherDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
CourseDao courseDao;
|
CourseDao courseDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PublishCourseUtil publishUtil;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
IEventDataSender eventSender;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -77,6 +94,8 @@ public class CourseAuditServiceImpl implements ICourseAuditService{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public List<SysLogAudit> findLogs(String courseId, String teacherId) {
|
// public List<SysLogAudit> findLogs(String courseId, String teacherId) {
|
||||||
//
|
//
|
||||||
@@ -121,4 +140,43 @@ public class CourseAuditServiceImpl implements ICourseAuditService{
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageList<CourseAuditRecord> pageRecord(int pageIndex, int pageSize, String courseName, Integer auditState,String aid) {
|
||||||
|
QueryBuilder builder=QueryBuilder.from(CourseAuditRecord.class);
|
||||||
|
builder.setPageIndex(pageIndex);
|
||||||
|
builder.setPageSize(pageSize);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void submitAudit(CourseAuditRecord record) {
|
||||||
|
|
||||||
|
auditRecordDao.save(record);
|
||||||
|
//同步发布课程
|
||||||
|
//同步发布
|
||||||
|
Course c= courseDao.get(record.getCourseId());
|
||||||
|
publishUtil.fullTextPublish(c);
|
||||||
|
//发布事件处理
|
||||||
|
if(eventSender!=null) {
|
||||||
|
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", record.getCourseId()));
|
||||||
|
if(teachers.size()>0) {
|
||||||
|
String authorIds="";
|
||||||
|
for(CourseTeacher cteacher:teachers) {
|
||||||
|
if(authorIds.equals("")) {
|
||||||
|
authorIds+=cteacher.getTeacherId();
|
||||||
|
}else {
|
||||||
|
authorIds+="|"+cteacher.getTeacherId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eventSender.send("发布课程","PublishCourse", "发布课程【"+record.getCourseName()+"】",record.getCourseId(), "1", record.getCourseName(), record.getAid(),record.getAname(),"authors:"+authorIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
log.error("未配置事件消息发送的实现");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import com.xboe.module.course.dao.CourseSectionDao;
|
|||||||
import com.xboe.module.course.dao.CourseTeacherDao;
|
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||||
import com.xboe.module.course.dao.CourseUpdateLogDao;
|
import com.xboe.module.course.dao.CourseUpdateLogDao;
|
||||||
import com.xboe.module.course.dto.CourseFullDto;
|
import com.xboe.module.course.dto.CourseFullDto;
|
||||||
import com.xboe.module.course.dto.CourseFullText;
|
|
||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
import com.xboe.module.course.dto.CourseQueryDto;
|
||||||
import com.xboe.module.course.dto.RankingDto;
|
import com.xboe.module.course.dto.RankingDto;
|
||||||
import com.xboe.module.course.entity.Course;
|
import com.xboe.module.course.entity.Course;
|
||||||
@@ -47,7 +46,6 @@ import com.xboe.module.course.entity.CourseHRBPAudit;
|
|||||||
import com.xboe.module.course.entity.CourseSection;
|
import com.xboe.module.course.entity.CourseSection;
|
||||||
import com.xboe.module.course.entity.CourseTeacher;
|
import com.xboe.module.course.entity.CourseTeacher;
|
||||||
import com.xboe.module.course.entity.CourseUpdateLog;
|
import com.xboe.module.course.entity.CourseUpdateLog;
|
||||||
import com.xboe.module.course.service.CourseToCourseFullText;
|
|
||||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||||
import com.xboe.module.course.service.ICourseService;
|
import com.xboe.module.course.service.ICourseService;
|
||||||
import com.xboe.module.interaction.service.ICourseGradeService;
|
import com.xboe.module.interaction.service.ICourseGradeService;
|
||||||
@@ -105,6 +103,9 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private ICourseFullTextSearch fullTextSearch;
|
private ICourseFullTextSearch fullTextSearch;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PublishCourseUtil publishUtil;
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private IEventDataSender eventSender;
|
private IEventDataSender eventSender;
|
||||||
|
|
||||||
@@ -459,11 +460,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
courseDao.update(course);
|
courseDao.update(course);
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(course.getFullTextId())) {
|
if(StringUtils.isNotBlank(course.getFullTextId())) {
|
||||||
try {
|
publishUtil.removeByDocId(course.getFullTextId());
|
||||||
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME,course.getFullTextId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
//log.error("删除课程时删除全文索引错误",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//记录日志
|
//记录日志
|
||||||
@@ -483,11 +480,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
Course c=courseDao.get(id);
|
Course c=courseDao.get(id);
|
||||||
//删除分两种情况,一个是管理员删除,一个是自己删除 ,所以这里的处理移到前端了
|
//删除分两种情况,一个是管理员删除,一个是自己删除 ,所以这里的处理移到前端了
|
||||||
if(c.getFullTextId()!=null) {
|
if(c.getFullTextId()!=null) {
|
||||||
try {
|
publishUtil.removeByDocId(c.getFullTextId());
|
||||||
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME,c.getFullTextId());
|
|
||||||
}catch(Exception e) {
|
|
||||||
log.error("删除课程时删除全文索引错误",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//只有速有全文检索返回标识的,才算是发布过再删除的,删除消息
|
//只有速有全文检索返回标识的,才算是发布过再删除的,删除消息
|
||||||
if(StringUtils.isNotBlank(c.getFullTextId())){
|
if(StringUtils.isNotBlank(c.getFullTextId())){
|
||||||
@@ -660,11 +653,8 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
|
|
||||||
//更新后需要删除发布
|
//更新后需要删除发布
|
||||||
if(StringUtils.isNotBlank(c.getFullTextId())) {
|
if(StringUtils.isNotBlank(c.getFullTextId())) {
|
||||||
try {
|
publishUtil.removeByDocId(c.getFullTextId());
|
||||||
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME,c.getFullTextId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
//log.error("删除课程时删除全文索引错误",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -723,7 +713,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitAndPublish(CourseFullDto full) throws Exception {
|
public void submitAndPublish(CourseFullDto full,String aid,String aname) throws Exception {
|
||||||
|
|
||||||
Course c=full.getCourse();//当前的课程信息
|
Course c=full.getCourse();//当前的课程信息
|
||||||
c.setPublished(true);
|
c.setPublished(true);
|
||||||
@@ -746,7 +736,26 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
courseCrowdDao.saveOrUpdate(cc);
|
courseCrowdDao.saveOrUpdate(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//同步发布
|
||||||
|
publishUtil.fullTextPublish(c);
|
||||||
|
//发布事件处理
|
||||||
|
if(eventSender!=null) {
|
||||||
|
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", c.getId()));
|
||||||
|
if(teachers.size()>0) {
|
||||||
|
String authorIds="";
|
||||||
|
for(CourseTeacher cteacher:teachers) {
|
||||||
|
if(authorIds.equals("")) {
|
||||||
|
authorIds+=cteacher.getTeacherId();
|
||||||
|
}else {
|
||||||
|
authorIds+="|"+cteacher.getTeacherId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eventSender.send("发布课程","PublishCourse", "发布课程【"+c.getName()+"】", c.getId(), "1", c.getName(), aid,aname,"authors:"+authorIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
log.error("未配置事件消息发送的实现");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,64 +787,64 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
* 发布全文索引
|
* 发布全文索引
|
||||||
* @param c
|
* @param c
|
||||||
*/
|
*/
|
||||||
private void fullTextPublish(Course c) {
|
// private void fullTextPublish(Course c) {
|
||||||
if(fullTextSearch==null) {
|
// if(fullTextSearch==null) {
|
||||||
log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
// log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
CourseFullText cft=CourseToCourseFullText.convert(c);
|
// CourseFullText cft=CourseToCourseFullText.convert(c);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
//计算课程时长
|
// //计算课程时长
|
||||||
int duration=courseContentDao.sumDurationByCourseId(c.getId());
|
// int duration=courseContentDao.sumDurationByCourseId(c.getId());
|
||||||
cft.setDuration(duration);
|
// cft.setDuration(duration);
|
||||||
cft.setType(c.getType());
|
// cft.setType(c.getType());
|
||||||
|
//
|
||||||
//查询教师
|
// //查询教师
|
||||||
List<String> teacherNames=new ArrayList<>();
|
// List<String> teacherNames=new ArrayList<>();
|
||||||
List<CourseTeacher> list = courseTeacherDao.findList(FieldFilters.eq("courseId",c.getId()));
|
// List<CourseTeacher> list = courseTeacherDao.findList(FieldFilters.eq("courseId",c.getId()));
|
||||||
if(list != null && !list.isEmpty()){
|
// if(list != null && !list.isEmpty()){
|
||||||
|
//
|
||||||
for (CourseTeacher ct : list){
|
// for (CourseTeacher ct : list){
|
||||||
teacherNames.add(ct.getTeacherName());
|
// teacherNames.add(ct.getTeacherName());
|
||||||
}
|
// }
|
||||||
cft.setTeacher(StringUtils.join(teacherNames,","));
|
// cft.setTeacher(StringUtils.join(teacherNames,","));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//查询课程受众
|
// //查询课程受众
|
||||||
List<CourseCrowd> crowds =this.findCrowdByCourseId(c.getId());
|
// List<CourseCrowd> crowds =this.findCrowdByCourseId(c.getId());
|
||||||
if(crowds!=null && !crowds.isEmpty()) {
|
// if(crowds!=null && !crowds.isEmpty()) {
|
||||||
String[] crowdIds=new String[crowds.size()];
|
// String[] crowdIds=new String[crowds.size()];
|
||||||
for(int i=0;i<crowds.size();i++) {
|
// for(int i=0;i<crowds.size();i++) {
|
||||||
crowdIds[i]=crowds.get(i).getGroupId();
|
// crowdIds[i]=crowds.get(i).getGroupId();
|
||||||
}
|
// }
|
||||||
//String audienceIds=StringUtils.join(crowdIds,",");
|
// //String audienceIds=StringUtils.join(crowdIds,",");
|
||||||
//log.info("受众信息",audienceIds);
|
// //log.info("受众信息",audienceIds);
|
||||||
//cft.setAudience(audienceIds);
|
// //cft.setAudience(audienceIds);
|
||||||
cft.setAudiences(crowdIds);
|
// cft.setAudiences(crowdIds);
|
||||||
//cft.setAudiences(new String[]{"0C76ECF8-5A14-B6B3-A513-CD22AE912B3E"});
|
// //cft.setAudiences(new String[]{"0C76ECF8-5A14-B6B3-A513-CD22AE912B3E"});
|
||||||
cft.setIsSetAudience(1);//有受众
|
// cft.setIsSetAudience(1);//有受众
|
||||||
}else {
|
// }else {
|
||||||
cft.setIsSetAudience(0);//无受众
|
// cft.setIsSetAudience(0);//无受众
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//String fullTextId="";//全文检索返回的id,用于移除时处理
|
// //String fullTextId="";//全文检索返回的id,用于移除时处理
|
||||||
String newFullId=fullTextSearch.republish(ICourseFullTextSearch.DEFAULT_INDEX_NAME, cft, c.getFullTextId());
|
// String newFullId=fullTextSearch.republish(ICourseFullTextSearch.DEFAULT_INDEX_NAME, cft, c.getFullTextId());
|
||||||
if(StringUtils.isNotBlank(c.getFullTextId())) {
|
// if(StringUtils.isNotBlank(c.getFullTextId())) {
|
||||||
if(StringUtils.isNotBlank(newFullId) && !c.getFullTextId().equals(newFullId)) {
|
// if(StringUtils.isNotBlank(newFullId) && !c.getFullTextId().equals(newFullId)) {
|
||||||
this.updateFieldById(c.getId(),"fullTextId", newFullId);
|
// this.updateFieldById(c.getId(),"fullTextId", newFullId);
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
if(StringUtils.isNotBlank(newFullId)) {
|
// if(StringUtils.isNotBlank(newFullId)) {
|
||||||
this.updateFieldById(c.getId(),"fullTextId", newFullId);
|
// this.updateFieldById(c.getId(),"fullTextId", newFullId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}catch(Exception e) {
|
// }catch(Exception e) {
|
||||||
log.error("课程发布全文检索失败",e);
|
// log.error("课程发布全文检索失败",e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void audit(String auditId, String courseId, Boolean pass, String aid, String name, String remark,boolean publish,Integer from) {
|
public void audit(String auditId, String courseId, Boolean pass, String aid, String name, String remark,boolean publish,Integer from) {
|
||||||
@@ -884,10 +893,11 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
UpdateBuilder.create("erasable", false), //设置以后不能物理删除了
|
UpdateBuilder.create("erasable", false), //设置以后不能物理删除了
|
||||||
UpdateBuilder.create("publishTime", LocalDateTime.now()));
|
UpdateBuilder.create("publishTime", LocalDateTime.now()));
|
||||||
//发布到全文检索中
|
//发布到全文检索中
|
||||||
Course c=courseDao.get(courseId);
|
Course c=courseDao.get(courseId);
|
||||||
if(fullTextSearch!=null) {
|
// if(fullTextSearch!=null) {
|
||||||
this.fullTextPublish(c);
|
// this.fullTextPublish(c);
|
||||||
}
|
// }
|
||||||
|
publishUtil.fullTextPublish(c);
|
||||||
//同时添加发布事件,这里的创建人需要修改为教师
|
//同时添加发布事件,这里的创建人需要修改为教师
|
||||||
if(eventSender!=null) {
|
if(eventSender!=null) {
|
||||||
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId));
|
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId));
|
||||||
@@ -921,20 +931,16 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
//发布到全文检索中
|
//发布到全文检索中
|
||||||
if(fullTextSearch!=null) {
|
if(fullTextSearch!=null) {
|
||||||
Course c=courseDao.get(id);
|
Course c=courseDao.get(id);
|
||||||
this.fullTextPublish(c);
|
//this.fullTextPublish(c);
|
||||||
|
publishUtil.fullTextPublish(c);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
courseDao.updateMultiFieldById(id,
|
courseDao.updateMultiFieldById(id,UpdateBuilder.create("published", pass));
|
||||||
UpdateBuilder.create("published", pass));
|
|
||||||
|
|
||||||
if(this.fullTextSearch!=null) {
|
if(this.fullTextSearch!=null) {
|
||||||
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
||||||
if(fullId!=null) {
|
if(fullId!=null) {
|
||||||
try {
|
publishUtil.removeByDocId((String)fullId);
|
||||||
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME, (String)fullId);
|
|
||||||
}catch(Exception e) {
|
|
||||||
log.error("更新全文索引字段错误",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -957,11 +963,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
if(this.fullTextSearch!=null) {
|
if(this.fullTextSearch!=null) {
|
||||||
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
||||||
if(fullId!=null) {
|
if(fullId!=null) {
|
||||||
try {
|
publishUtil.updateFieldByDocId((String)fullId, "isTop", top?1:0);
|
||||||
fullTextSearch.updateField(ICourseFullTextSearch.DEFAULT_INDEX_NAME, "isTop", top?1:0, (String)fullId);
|
|
||||||
}catch(Exception e) {
|
|
||||||
log.error("更新全文索引字段错误",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,15 +978,12 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
if(this.fullTextSearch!=null) {
|
if(this.fullTextSearch!=null) {
|
||||||
if(enabled) { //启用,重新必
|
if(enabled) { //启用,重新必
|
||||||
Course c=courseDao.get(id);
|
Course c=courseDao.get(id);
|
||||||
this.fullTextPublish(c);
|
//this.fullTextPublish(c);
|
||||||
|
publishUtil.fullTextPublish(c);
|
||||||
}else {
|
}else {
|
||||||
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
Object fullId=courseDao.findField("fullTextId", FieldFilters.eq("id", id));
|
||||||
if(fullId!=null) {
|
if(fullId!=null) {
|
||||||
try {
|
publishUtil.removeByDocId((String)fullId);
|
||||||
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME, (String)fullId);
|
|
||||||
}catch(Exception e) {
|
|
||||||
log.error("停用,从索引中删除课程失败",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.xboe.module.course.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
|
import com.xboe.module.course.dao.CourseCrowdDao;
|
||||||
|
import com.xboe.module.course.dao.CourseDao;
|
||||||
|
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||||
|
import com.xboe.module.course.dto.CourseFullText;
|
||||||
|
import com.xboe.module.course.entity.Course;
|
||||||
|
import com.xboe.module.course.entity.CourseCrowd;
|
||||||
|
import com.xboe.module.course.entity.CourseTeacher;
|
||||||
|
import com.xboe.module.course.service.CourseToCourseFullText;
|
||||||
|
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布课程的工具类
|
||||||
|
* @author seastar
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class PublishCourseUtil {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CourseDao courseDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CourseContentDao courseContentDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CourseTeacherDao courseTeacherDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CourseCrowdDao courseCrowdDao;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private ICourseFullTextSearch fullTextSearch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布课程
|
||||||
|
* @param c
|
||||||
|
*/
|
||||||
|
public void fullTextPublish(Course c) {
|
||||||
|
if(fullTextSearch==null) {
|
||||||
|
log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CourseFullText cft=CourseToCourseFullText.convert(c);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
//计算课程时长
|
||||||
|
int duration=courseContentDao.sumDurationByCourseId(c.getId());
|
||||||
|
cft.setDuration(duration);
|
||||||
|
cft.setType(c.getType());
|
||||||
|
|
||||||
|
//查询教师
|
||||||
|
List<String> teacherNames=new ArrayList<>();
|
||||||
|
List<CourseTeacher> list = courseTeacherDao.findList(FieldFilters.eq("courseId",c.getId()));
|
||||||
|
if(list != null && !list.isEmpty()){
|
||||||
|
|
||||||
|
for (CourseTeacher ct : list){
|
||||||
|
teacherNames.add(ct.getTeacherName());
|
||||||
|
}
|
||||||
|
cft.setTeacher(StringUtils.join(teacherNames,","));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询课程受众
|
||||||
|
//List<CourseCrowd> crowds =this.findCrowdByCourseId(c.getId());
|
||||||
|
List<CourseCrowd> crowds =courseCrowdDao.findList("courseId", c.getId());
|
||||||
|
if(crowds!=null && !crowds.isEmpty()) {
|
||||||
|
String[] crowdIds=new String[crowds.size()];
|
||||||
|
for(int i=0;i<crowds.size();i++) {
|
||||||
|
crowdIds[i]=crowds.get(i).getGroupId();
|
||||||
|
}
|
||||||
|
//String audienceIds=StringUtils.join(crowdIds,",");
|
||||||
|
//log.info("受众信息",audienceIds);
|
||||||
|
//cft.setAudience(audienceIds);
|
||||||
|
cft.setAudiences(crowdIds);
|
||||||
|
//cft.setAudiences(new String[]{"0C76ECF8-5A14-B6B3-A513-CD22AE912B3E"});
|
||||||
|
cft.setIsSetAudience(1);//有受众
|
||||||
|
}else {
|
||||||
|
cft.setIsSetAudience(0);//无受众
|
||||||
|
}
|
||||||
|
|
||||||
|
//String fullTextId="";//全文检索返回的id,用于移除时处理
|
||||||
|
String newFullId=fullTextSearch.republish(ICourseFullTextSearch.DEFAULT_INDEX_NAME, cft, c.getFullTextId());
|
||||||
|
if(StringUtils.isNotBlank(c.getFullTextId())) {
|
||||||
|
if(StringUtils.isNotBlank(newFullId) && !c.getFullTextId().equals(newFullId)) {
|
||||||
|
courseDao.updateFieldById(c.getId(), "fullTextId", newFullId);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if(StringUtils.isNotBlank(newFullId)) {
|
||||||
|
courseDao.updateFieldById(c.getId(), "fullTextId", newFullId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("课程发布全文检索失败",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateFieldByDocId(String docId,String field,Object value) {
|
||||||
|
try {
|
||||||
|
fullTextSearch.updateField(ICourseFullTextSearch.DEFAULT_INDEX_NAME, field,value,docId);
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("更新全文索引字段错误",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeByDocId(String docId){
|
||||||
|
if(fullTextSearch==null) {
|
||||||
|
log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
fullTextSearch.removeByDocId(ICourseFullTextSearch.DEFAULT_INDEX_NAME, docId);
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("停用,从索引中删除课程失败",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user