添加已读操作逻辑

beetlsql3-dev
yaodan 2 years ago
parent 8dde08da8a
commit 218b477b31

@ -1,6 +1,7 @@
package com.ibeetl.jlw.service; package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
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.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -38,6 +39,8 @@ import javax.validation.constraints.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
@ -49,9 +52,10 @@ import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
@Service @Service
@Transactional @Transactional
@Slf4j @Slf4j
public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpenCourseChatLog> implements DeleteResourcesBy{ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpenCourseChatLog> implements DeleteResourcesBy {
@Autowired private TeacherOpenCourseChatLogDao teacherOpenCourseChatLogDao; @Autowired
private TeacherOpenCourseChatLogDao teacherOpenCourseChatLogDao;
@Autowired @Autowired
private TeacherDao teacherDao; private TeacherDao teacherDao;
@Autowired @Autowired
@ -59,8 +63,8 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
@Autowired @Autowired
private WebPlatformService webPlatformService; private WebPlatformService webPlatformService;
public PageQuery<TeacherOpenCourseChatLog>queryByCondition(PageQuery query){ public PageQuery<TeacherOpenCourseChatLog> queryByCondition(PageQuery query) {
PageQuery<TeacherOpenCourseChatLog> ret = teacherOpenCourseChatLogDao.queryByCondition(query); PageQuery<TeacherOpenCourseChatLog> ret = teacherOpenCourseChatLogDao.queryByCondition(query);
CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> { CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> {
String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId()); String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId());
item.set("headImg", headImg); item.set("headImg", headImg);
@ -68,8 +72,9 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
queryListAfter(ret.getList()); queryListAfter(ret.getList());
return ret; return ret;
} }
public PageQuery<TeacherOpenCourseChatLogTree> queryByCondition(PageQuery query, Boolean placeholder){
PageQuery<TeacherOpenCourseChatLogTree> ret = teacherOpenCourseChatLogDao.queryByCondition2(query); public PageQuery<TeacherOpenCourseChatLogTree> queryByCondition(PageQuery query, Boolean placeholder) {
PageQuery<TeacherOpenCourseChatLogTree> ret = teacherOpenCourseChatLogDao.queryByCondition2(query);
CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> { CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> {
String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId()); String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId());
item.set("headImg", headImg); item.set("headImg", headImg);
@ -78,8 +83,8 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
return ret; return ret;
} }
public PageQuery<TeacherOpenCourseChatLog>queryByConditionQuery(PageQuery query){ public PageQuery<TeacherOpenCourseChatLog> queryByConditionQuery(PageQuery query) {
PageQuery<TeacherOpenCourseChatLog> ret = teacherOpenCourseChatLogDao.queryByConditionQuery(query); PageQuery<TeacherOpenCourseChatLog> ret = teacherOpenCourseChatLogDao.queryByConditionQuery(query);
CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> { CollectionUtil.emptyIfNull(ret.getList()).forEach(item -> {
String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId()); String headImg = webPlatformService.getHeadImgByIdentity(item.getUserId());
item.set("headImg", headImg); item.set("headImg", headImg);
@ -88,18 +93,106 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
return ret; return ret;
} }
public void deleteByList(List list){ 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 = ""; String ids = "";
ToolUtils.deleteNullList(list); ToolUtils.deleteNullList(list);
for(int i=0;null != list && i<list.size();i++){ for (int i = 0; null != list && i < list.size(); i++) {
ids += list.get(i).toString()+(i==list.size()-1?"":","); ids += list.get(i).toString() + (i == list.size() - 1 ? "" : ",");
} }
if(StringUtils.isNotBlank(ids)){ if (StringUtils.isNotBlank(ids)) {
teacherOpenCourseChatLogDao.deleteByIds(ids); teacherOpenCourseChatLogDao.deleteByIds(ids);
} }
} }
public void deleteTeacherOpenCourseChatLog(String ids){ public void deleteTeacherOpenCourseChatLog(String ids) {
try { try {
teacherOpenCourseChatLogDao.deleteTeacherOpenCourseChatLogByIds(ids); teacherOpenCourseChatLogDao.deleteTeacherOpenCourseChatLogByIds(ids);
} catch (Exception e) { } catch (Exception e) {
@ -107,7 +200,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
} }
} }
public String addAll(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public String addAll(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
String msg = ""; String msg = "";
List<TeacherOpenCourseChatLog> teacherOpenCourseChatLogList = new ArrayList<>(); List<TeacherOpenCourseChatLog> teacherOpenCourseChatLogList = new ArrayList<>();
try { try {
@ -115,11 +208,12 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
} catch (Exception e) { } catch (Exception e) {
try { try {
teacherOpenCourseChatLogList.add(JSONObject.parseObject(teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogJsonStr(), TeacherOpenCourseChatLog.class)); teacherOpenCourseChatLogList.add(JSONObject.parseObject(teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogJsonStr(), TeacherOpenCourseChatLog.class));
} catch (Exception e1) {} } catch (Exception e1) {
}
} }
ToolUtils.deleteNullList(teacherOpenCourseChatLogList); ToolUtils.deleteNullList(teacherOpenCourseChatLogList);
if(null != teacherOpenCourseChatLogList && teacherOpenCourseChatLogList.size()>0){ if (null != teacherOpenCourseChatLogList && teacherOpenCourseChatLogList.size() > 0) {
for(int i=0;i<teacherOpenCourseChatLogList.size();i++){ for (int i = 0; i < teacherOpenCourseChatLogList.size(); i++) {
TeacherOpenCourseChatLog teacherOpenCourseChatLog = teacherOpenCourseChatLogList.get(i); TeacherOpenCourseChatLog teacherOpenCourseChatLog = teacherOpenCourseChatLogList.get(i);
teacherOpenCourseChatLog.setTeacherOpenCourseChatLogAddTime(new Date()); teacherOpenCourseChatLog.setTeacherOpenCourseChatLogAddTime(new Date());
teacherOpenCourseChatLog.setUserId(teacherOpenCourseChatLogQuery.getUserId()); teacherOpenCourseChatLog.setUserId(teacherOpenCourseChatLogQuery.getUserId());
@ -130,7 +224,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
return msg; return msg;
} }
public JsonResult add(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public JsonResult add(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
String msg = ""; String msg = "";
TeacherOpenCourseChatLog teacherOpenCourseChatLog = teacherOpenCourseChatLogQuery.pojo(); TeacherOpenCourseChatLog teacherOpenCourseChatLog = teacherOpenCourseChatLogQuery.pojo();
@ -165,6 +259,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
/** /**
* ID * ID
*
* @param chatLog * @param chatLog
* @return * @return
*/ */
@ -207,60 +302,60 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
Assert.isTrue(validationResult.isSuccess(), JSONUtil.toJsonStr(validationResult.getErrorMessages())); Assert.isTrue(validationResult.isSuccess(), JSONUtil.toJsonStr(validationResult.getErrorMessages()));
// 教师身份添加上级ID为0 // 教师身份添加上级ID为0
if(isTeacherAdding) { if (isTeacherAdding) {
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogParentId(0L); teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogParentId(0L);
} }
if(null == teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogStatus()){ if (null == teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogStatus()) {
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatus(1); teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatus(1);
} }
return add(teacherOpenCourseChatLogQuery); return add(teacherOpenCourseChatLogQuery);
} }
public String edit(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public String edit(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
String msg = ""; String msg = "";
teacherOpenCourseChatLogDao.updateTemplateById(BeanUtil.copyProperties(teacherOpenCourseChatLogQuery, TeacherOpenCourseChatLog.class)); teacherOpenCourseChatLogDao.updateTemplateById(BeanUtil.copyProperties(teacherOpenCourseChatLogQuery, TeacherOpenCourseChatLog.class));
return msg; return msg;
} }
public String updateGivenByIds(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public String updateGivenByIds(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
String msg = ""; String msg = "";
if(StringUtils.isNotBlank(teacherOpenCourseChatLogQuery.get_given())){ if (StringUtils.isNotBlank(teacherOpenCourseChatLogQuery.get_given())) {
boolean flag = teacherOpenCourseChatLogDao.updateGivenByIds(teacherOpenCourseChatLogQuery) > 0; boolean flag = teacherOpenCourseChatLogDao.updateGivenByIds(teacherOpenCourseChatLogQuery) > 0;
if(!flag){ if (!flag) {
msg = "更新指定参数失败"; msg = "更新指定参数失败";
} }
}else{ } else {
msg = "指定参数为空"; msg = "指定参数为空";
} }
return msg; return msg;
} }
public List<TeacherOpenCourseChatLog> getValues (Object paras){ public List<TeacherOpenCourseChatLog> getValues(Object paras) {
return sqlManager.select(SqlId.of("jlw.teacherOpenCourseChatLog.getTeacherOpenCourseChatLogValues"), TeacherOpenCourseChatLog.class, paras); return sqlManager.select(SqlId.of("jlw.teacherOpenCourseChatLog.getTeacherOpenCourseChatLogValues"), TeacherOpenCourseChatLog.class, paras);
} }
public List<TeacherOpenCourseChatLog> getValuesByQuery (TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public List<TeacherOpenCourseChatLog> getValuesByQuery(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
return teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery); return teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery);
} }
public TeacherOpenCourseChatLog getInfo (Long teacherOpenCourseChatLogId){ public TeacherOpenCourseChatLog getInfo(Long teacherOpenCourseChatLogId) {
TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery = new TeacherOpenCourseChatLogQuery(); TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery = new TeacherOpenCourseChatLogQuery();
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogId(teacherOpenCourseChatLogId); teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogId(teacherOpenCourseChatLogId);
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatusPlural("1,2");//需要根据实际情况来 teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatusPlural("1,2");//需要根据实际情况来
List<TeacherOpenCourseChatLog> list = teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery); List<TeacherOpenCourseChatLog> list = teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery);
if(null != list && list.size()>0){ if (null != list && list.size() > 0) {
return list.get(0); return list.get(0);
}else{ } else {
return null; return null;
} }
} }
public TeacherOpenCourseChatLog getInfo (TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery){ public TeacherOpenCourseChatLog getInfo(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery) {
List<TeacherOpenCourseChatLog> list = teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery); List<TeacherOpenCourseChatLog> list = teacherOpenCourseChatLogDao.getValuesByQuery(teacherOpenCourseChatLogQuery);
if(null != list && list.size()>0){ if (null != list && list.size() > 0) {
return list.get(0); return list.get(0);
}else{ } else {
return null; return null;
} }
} }
@ -279,7 +374,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
* : <br> * : <br>
* - * -
* *
* @param teacherOpenCourseId ID * @param teacherOpenCourseId ID
* @return {@link TeacherOpenCourseChatLogAnalysis} * @return {@link TeacherOpenCourseChatLogAnalysis}
* @Author: lx * @Author: lx
* @Date: 2022/12/12 23:14 * @Date: 2022/12/12 23:14
@ -292,7 +387,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
* : <br> * : <br>
* *
* *
* @param teacherOpenCourseId ID * @param teacherOpenCourseId ID
* @return {@link List< TeacherOpenCourseChatLogGroupInfoVO>} * @return {@link List< TeacherOpenCourseChatLogGroupInfoVO>}
* @Author: lx * @Author: lx
* @Date: 2022/12/12 23:14 * @Date: 2022/12/12 23:14
@ -303,6 +398,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
/** /**
* *
*
* @param dto * @param dto
* @return * @return
*/ */
@ -344,7 +440,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
* @param dto dto * @param dto dto
* @author zhouzhao * @author zhouzhao
* @date 2023/05/06 02:13:50 * @date 2023/05/06 02:13:50
* @desc 0 1 * @desc 0 1
*/ */
public Integer getTeacherAskUnReadCount(ChatLogUnReadNumDTO dto) { public Integer getTeacherAskUnReadCount(ChatLogUnReadNumDTO dto) {
@ -355,13 +451,13 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
Teacher teacher = teacherDao.getByUserId(user.getId()); Teacher teacher = teacherDao.getByUserId(user.getId());
if (teacher != null) { if (teacher != null) {
dto.setTeacherId(teacher.getTeacherId()); dto.setTeacherId(teacher.getTeacherId());
count = teacherOpenCourseChatLogDao.getTeacherAskUnReadCountByTeacher(dto); count = teacherOpenCourseChatLogDao.getTeacherAskUnReadCountByTeacher(dto);
} }
}else if (user != null && user.isStudent()) { } else if (user != null && user.isStudent()) {
Student student = studentDao.getByUserId(user.getId()); Student student = studentDao.getByUserId(user.getId());
if (student != null) { if (student != null) {
dto.setStudentId(student.getStudentId()); dto.setStudentId(student.getStudentId());
count = teacherOpenCourseChatLogDao.getTeacherAskUnReadCountByStudent(dto); count = teacherOpenCourseChatLogDao.getTeacherAskUnReadCountByStudent(dto);
} }
} }
@ -375,7 +471,7 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
* @param dto dto * @param dto dto
* @author zhouzhao * @author zhouzhao
* @date 2023/05/06 02:14:44 * @date 2023/05/06 02:14:44
* @desc 0 1 * @desc 0 1
*/ */
public Integer getStudentAskUnReadCount(ChatLogUnReadNumDTO dto) { public Integer getStudentAskUnReadCount(ChatLogUnReadNumDTO dto) {
CoreUser user = getUser(); CoreUser user = getUser();
@ -385,13 +481,13 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService<TeacherOpen
Teacher teacher = teacherDao.getByUserId(user.getId()); Teacher teacher = teacherDao.getByUserId(user.getId());
if (teacher != null) { if (teacher != null) {
dto.setTeacherId(teacher.getTeacherId()); dto.setTeacherId(teacher.getTeacherId());
count = teacherOpenCourseChatLogDao.getStudentAskUnReadCountByTeacher(dto); count = teacherOpenCourseChatLogDao.getStudentAskUnReadCountByTeacher(dto);
} }
}else if (user != null && user.isStudent()) { } else if (user != null && user.isStudent()) {
Student student = studentDao.getByUserId(user.getId()); Student student = studentDao.getByUserId(user.getId());
if (student != null) { if (student != null) {
dto.setStudentId(student.getStudentId()); dto.setStudentId(student.getStudentId());
count = teacherOpenCourseChatLogDao.getStudentAskUnReadCountByStudent(dto); count = teacherOpenCourseChatLogDao.getStudentAskUnReadCountByStudent(dto);
} }
} }

@ -1,6 +1,7 @@
package com.ibeetl.jlw.web; package com.ibeetl.jlw.web;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -40,6 +41,7 @@ import java.math.BigDecimal;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.ibeetl.admin.core.util.ExcelUtil.convertData; import static com.ibeetl.admin.core.util.ExcelUtil.convertData;
@ -74,9 +76,7 @@ public class TeacherOpenCourseChatLogController extends BaseController {
if (null == coreUser) { if (null == coreUser) {
return JsonResult.failMessage("请登录后再操作"); return JsonResult.failMessage("请登录后再操作");
} else { } else {
PageQuery page = condition.getPageQuery(); return JsonResult.success(teacherOpenCourseChatLogService.queryByConditionQueryWithChangStatus(condition));
teacherOpenCourseChatLogService.queryByConditionQuery(page);
return JsonResult.success(page);
} }
} }
@ -138,12 +138,12 @@ public class TeacherOpenCourseChatLogController extends BaseController {
teacherOpenCourseChatLogQuery.setOrgId(coreUser.getOrgId()); teacherOpenCourseChatLogQuery.setOrgId(coreUser.getOrgId());
if (ObjectUtil.isNotEmpty(teacher)) { if (ObjectUtil.isNotEmpty(teacher)) {
teacherOpenCourseChatLogQuery.setTeacherId(teacher.getTeacherId()); teacherOpenCourseChatLogQuery.setTeacherId(teacher.getTeacherId());
teacherOpenCourseChatLogQuery.setStudentReadStatus(0);
} }
if (ObjectUtil.isNotEmpty(student)) { if (ObjectUtil.isNotEmpty(student)) {
teacherOpenCourseChatLogQuery.setStudentId(student.getStudentId()); teacherOpenCourseChatLogQuery.setStudentId(student.getStudentId());
teacherOpenCourseChatLogQuery.setTeacherReadStatus(0);
} }
teacherOpenCourseChatLogQuery.setTeacherReadStatus(0);
teacherOpenCourseChatLogQuery.setStudentReadStatus(0);
return teacherOpenCourseChatLogService.add(teacherOpenCourseChatLogQuery); return teacherOpenCourseChatLogService.add(teacherOpenCourseChatLogQuery);
} }
} }
@ -229,7 +229,16 @@ public class TeacherOpenCourseChatLogController extends BaseController {
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogId(teacherOpenCourseChatLogId); teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogId(teacherOpenCourseChatLogId);
teacherOpenCourseChatLogQuery.setStudentScore(studentScore); teacherOpenCourseChatLogQuery.setStudentScore(studentScore);
String msg = teacherOpenCourseChatLogService.edit(teacherOpenCourseChatLogQuery); String msg = teacherOpenCourseChatLogService.edit(teacherOpenCourseChatLogQuery);
if (StringUtils.isBlank(msg)) { if (StringUtils.isBlank(msg)) {
TeacherOpenCourseChatLog teacherOpenCourseChatLog = new TeacherOpenCourseChatLog();
teacherOpenCourseChatLog.setTeacherOpenCourseChatLogParentId(teacherOpenCourseChatLogId);
//获取所有子评论
List<TeacherOpenCourseChatLog> values = teacherOpenCourseChatLogService.getValues(teacherOpenCourseChatLog);
if (CollUtil.isNotEmpty(values)){
List<Long> idList = values.stream().filter(e-> Objects.equals(e.getTeacherReadStatus(),0)).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList());
teacherOpenCourseChatLogService.readChatLogByIds(idList,2);
}
return JsonResult.success(); return JsonResult.success();
} else { } else {
return JsonResult.failMessage("更新失败," + msg); return JsonResult.failMessage("更新失败," + msg);

@ -698,10 +698,10 @@ getTeacherAskUnReadCountByTeacher
=== ===
* 获取老师提问模块未读数量,对于老师来说 * 获取老师提问模块未读数量,对于老师来说
SELECT IFNULL(sum( SELECT IFNULL(sum(
(select count(*) IF((select count(*)
from teacher_open_course_chat_log t2 from teacher_open_course_chat_log t2
where t2.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id where t2.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id
and t2.teacher_read_status = 0) and t2.teacher_read_status = 0)>0,1,0)
),0) ),0)
FROM teacher_open_course_chat_log t FROM teacher_open_course_chat_log t
WHERE 1 WHERE 1
@ -727,8 +727,8 @@ getTeacherAskUnReadCountByStudent
SELECT 1 SELECT 1
FROM teacher_open_course_chat_log ta FROM teacher_open_course_chat_log ta
WHERE 1 WHERE 1
and t.student_id = #studentId# and ta.student_id = #studentId#
AND t.teacher_open_course_id = #teacherOpenCourseId# AND ta.teacher_open_course_id = #teacherOpenCourseId#
AND ta.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id AND ta.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id
) )
@ -746,8 +746,8 @@ getStudentAskUnReadCountByTeacher
SELECT 1 SELECT 1
FROM teacher_open_course_chat_log ta FROM teacher_open_course_chat_log ta
WHERE 1 WHERE 1
and t.teacher_id = #teacherId# and ta.teacher_id = #teacherId#
AND t.teacher_open_course_id = #teacherOpenCourseId# AND ta.teacher_open_course_id = #teacherOpenCourseId#
AND ta.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id AND ta.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id
) )
@ -760,7 +760,7 @@ getStudentAskUnReadCountByStudent
(select count(*) (select count(*)
from teacher_open_course_chat_log t2 from teacher_open_course_chat_log t2
where t2.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id where t2.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id
and t2.teacher_read_status = 0) and t2.student_read_status = 0)
),0) ),0)
FROM teacher_open_course_chat_log t FROM teacher_open_course_chat_log t
WHERE 1 WHERE 1

Loading…
Cancel
Save