|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
@ -38,6 +39,8 @@ import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
|
|
|
|
|
|
|
|
|
@ -51,7 +54,8 @@ import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpenCourseChatLog> implements DeleteResourcesBy {
|
|
|
|
|
|
|
|
|
|
@Autowired private TeacherOpenCourseChatLogDao teacherOpenCourseChatLogDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherOpenCourseChatLogDao teacherOpenCourseChatLogDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherDao teacherDao;
|
|
|
|
|
@Autowired
|
|
|
|
@ -68,6 +72,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseChatLogTree> queryByCondition(PageQuery query, Boolean placeholder) {
|
|
|
|
|
PageQuery<TeacherOpenCourseChatLogTree> ret = teacherOpenCourseChatLogDao.queryByCondition2(query);
|
|
|
|
|
CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> {
|
|
|
|
@ -88,6 +93,94 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseChatLog> queryByConditionQueryWithChangStatus(TeacherOpenCourseChatLogQuery query) {
|
|
|
|
|
PageQuery<TeacherOpenCourseChatLog> ret = teacherOpenCourseChatLogDao.queryByConditionQuery(query.getPageQuery());
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(ret.getList())) {
|
|
|
|
|
CoreUser user = getUser();
|
|
|
|
|
Object bean = null;
|
|
|
|
|
// 学生或者教师身份才能看到真正的数字
|
|
|
|
|
if (user != null && user.isTeacher()) {
|
|
|
|
|
Teacher teacher = teacherDao.getByUserId(user.getId());
|
|
|
|
|
if (teacher != null) {
|
|
|
|
|
bean = teacher;
|
|
|
|
|
}
|
|
|
|
|
} else if (user != null && user.isStudent()) {
|
|
|
|
|
Student student = studentDao.getByUserId(user.getId());
|
|
|
|
|
if (student != null) {
|
|
|
|
|
bean = student;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//remark /api/teacherOpenCourseChatLog/setScore.do 也有标记已读的逻辑
|
|
|
|
|
if (bean != null) {
|
|
|
|
|
switch (query.getChatLogSendType()==null?ChatLogSendTypeEnum.normal:query.getChatLogSendType()) {
|
|
|
|
|
case normal:
|
|
|
|
|
if (query.getTeacherOpenCourseChatLogParentId()!=null){
|
|
|
|
|
if (bean instanceof Student){
|
|
|
|
|
List<Long> idList = ret.getList().stream().filter(e->Objects.equals(e.getStudentReadStatus(),0)).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList());
|
|
|
|
|
readChatLogByIds(idList,1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case student_ask:
|
|
|
|
|
if (bean instanceof Teacher) {
|
|
|
|
|
List<Long> idList = ret.getList().stream().filter(e->Objects.equals(e.getTeacherReadStatus(),0)).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList());
|
|
|
|
|
readChatLogByIds(idList,2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case specify_ask:
|
|
|
|
|
case random_ask:
|
|
|
|
|
//if (bean instanceof Student) {
|
|
|
|
|
// List<Long> idList = ret.getList().stream().filter(e->Objects.equals(e.getStudentReadStatus(),0)).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList());
|
|
|
|
|
// readChatLogByIds(idList,1);
|
|
|
|
|
//}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> {
|
|
|
|
|
String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId());
|
|
|
|
|
item.set("headImg", headImg);
|
|
|
|
|
});
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 标记消息为已读
|
|
|
|
|
*
|
|
|
|
|
* @param ids id
|
|
|
|
|
* @param type 类型 1学生 2教师
|
|
|
|
|
* @author zhouzhao
|
|
|
|
|
* @date 2023/05/09 10:38:44
|
|
|
|
|
*/
|
|
|
|
|
public void readChatLogByIds(List<Long> ids,int type) {
|
|
|
|
|
if (CollUtil.isEmpty(ids)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (Long id : ids) {
|
|
|
|
|
TeacherOpenCourseChatLog teacherOpenCourseChatLog = teacherOpenCourseChatLogDao.unique(id);
|
|
|
|
|
if (teacherOpenCourseChatLog != null) {
|
|
|
|
|
if (type==1) {
|
|
|
|
|
teacherOpenCourseChatLog.setStudentReadStatus(1);
|
|
|
|
|
}else {
|
|
|
|
|
teacherOpenCourseChatLog.setTeacherReadStatus(1);
|
|
|
|
|
}
|
|
|
|
|
teacherOpenCourseChatLog.setTeacherReadStatus(1);
|
|
|
|
|
teacherOpenCourseChatLogDao.updateById(teacherOpenCourseChatLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list) {
|
|
|
|
|
String ids = "";
|
|
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
|
@ -115,7 +208,8 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseChatLogList.add(JSONObject.parseObject(teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogJsonStr(), TeacherOpenCourseChatLog.class));
|
|
|
|
|
} catch (Exception e1) {}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ToolUtils.deleteNullList(teacherOpenCourseChatLogList);
|
|
|
|
|
if (null != teacherOpenCourseChatLogList && teacherOpenCourseChatLogList.size() > 0) {
|
|
|
|
@ -165,6 +259,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取全路径的ID
|
|
|
|
|
*
|
|
|
|
|
* @param chatLog
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -303,6 +398,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据登录身份,互动获取未读数
|
|
|
|
|
*
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|