From 3689769ed97848620f8776723c73c068a7a9e6ae Mon Sep 17 00:00:00 2001 From: xuliangtong <1124839262@qq.com> Date: Thu, 22 Dec 2022 10:02:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E5=85=AC=E5=91=8A=E6=95=B0?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jlw/dao/TeacherOpenCourseNoticeDao.java | 1 + .../TeacherOpenCourseNoticeService.java | 27 +++++++ .../TeacherOpenCourseNoticeController.java | 9 +++ .../sql/jlw/teacherOpenCourseNotice.md | 72 ++++++++++++++++--- 4 files changed, 101 insertions(+), 8 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseNoticeDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseNoticeDao.java index 33c1bb87..23a36641 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseNoticeDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseNoticeDao.java @@ -26,6 +26,7 @@ public interface TeacherOpenCourseNoticeDao extends BaseMapper getByIds(String ids); List getValuesByQuery(TeacherOpenCourseNoticeQuery teacherOpenCourseNoticeQuery); + List getValuesByQueryNotWithPermission(TeacherOpenCourseNoticeQuery teacherOpenCourseNoticeQuery); List getClassByOpenCourseId(TeacherOpenCourseNotice teacherOpenCourseNotice); diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseNoticeService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseNoticeService.java index aadbdeca..6d2a1805 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseNoticeService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseNoticeService.java @@ -1,6 +1,7 @@ package com.ibeetl.jlw.service; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.NumberUtil; import cn.jlw.util.ToolUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -29,6 +30,7 @@ import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -218,4 +220,29 @@ public class TeacherOpenCourseNoticeService extends CoreBaseService getUnreadNotice(Long teacherOpenCourseId, CoreUser coreUser) { + if (coreUser.isStudent()) { + Long id = coreUser.getId(); + Student student = studentService.getByUserId(id); + if (student == null) { + return JsonResult.success(0); + } + Long classId = student.getClassId(); + TeacherOpenCourseNoticeQuery noticeQuery = new TeacherOpenCourseNoticeQuery(); + noticeQuery.setTeacherOpenCourseIds(teacherOpenCourseId+""); + noticeQuery.setSchoolClassIds(classId+""); + List noticeList = teacherOpenCourseNoticeDao.getValuesByQueryNotWithPermission(noticeQuery); + if (CollectionUtil.isEmpty(noticeList)) { + return JsonResult.success(0); + } + Set collect = noticeList.stream().map(TeacherOpenCourseNotice::getTeacherOpenCourseNoticeId).collect(Collectors.toSet()); + TeacherOpenCourseNoticeStudentQuery studentQuery = new TeacherOpenCourseNoticeStudentQuery(); + studentQuery.setTeacherOpenCourseNoticeIdPlural(CollectionUtil.join(collect, ",")); + studentQuery.setStudentId(student.getStudentId()); + List noticeStudents = noticeStudentService.getValuesByQueryNotWithPermission(studentQuery); + return JsonResult.success(NumberUtil.sub(collect.size() - noticeStudents.size()).intValue()); + } + return JsonResult.success(0); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseNoticeController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseNoticeController.java index fdabd3d9..1c627807 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseNoticeController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseNoticeController.java @@ -223,6 +223,15 @@ public class TeacherOpenCourseNoticeController{ return JsonResult.success(list); } + /** + * 获取未读公告数目 + * @return + */ + @GetMapping("/getUnreadNotice") + public JsonResult getUnreadNotice(Long teacherOpenCourseId, @SCoreUser CoreUser coreUser) { + return teacherOpenCourseNoticeService.getUnreadNotice(teacherOpenCourseId, coreUser); + } + } diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseNotice.md b/web/src/main/resources/sql/jlw/teacherOpenCourseNotice.md index c5e3a7f7..8ece7e09 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseNotice.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseNotice.md @@ -17,10 +17,10 @@ queryByCondition and find_in_set(t.teacher_open_course_notice_id,#teacherOpenCourseNoticeIdPlural#) @} @if(!isEmpty(schoolClassIds)){ - and t.school_class_ids =#schoolClassIds# + and (find_in_set(#schoolClassIds#, t.school_class_ids) or t.school_class_ids = "ALL") @} @if(!isEmpty(teacherOpenCourseIds)){ - and t.teacher_open_course_ids =#teacherOpenCourseIds# + and (find_in_set(#teacherOpenCourseIds#, t.teacher_open_course_ids) or t.teacher_open_course_ids = "ALL") @} @if(!isEmpty(noticeTitle)){ and t.notice_title =#noticeTitle# @@ -71,10 +71,10 @@ queryByConditionQuery and find_in_set(t.teacher_open_course_notice_id,#teacherOpenCourseNoticeIdPlural#) @} @if(!isEmpty(schoolClassIds)){ - and t.school_class_ids =#schoolClassIds# + and (find_in_set(#schoolClassIds#, t.school_class_ids) or t.school_class_ids = "ALL") @} @if(!isEmpty(teacherOpenCourseIds)){ - and t.teacher_open_course_ids =#teacherOpenCourseIds# + and (find_in_set(#teacherOpenCourseIds#, t.teacher_open_course_ids) or t.teacher_open_course_ids = "ALL") @} @if(!isEmpty(noticeTitle)){ and t.notice_title =#noticeTitle# @@ -212,10 +212,10 @@ getTeacherOpenCourseNoticeValues and t.teacher_open_course_notice_id =#teacherOpenCourseNoticeId# @} @if(!isEmpty(schoolClassIds)){ - and t.school_class_ids =#schoolClassIds# + and (find_in_set(#schoolClassIds#, t.school_class_ids) or t.school_class_ids = "ALL") @} @if(!isEmpty(teacherOpenCourseIds)){ - and t.teacher_open_course_ids =#teacherOpenCourseIds# + and (find_in_set(#teacherOpenCourseIds#, t.teacher_open_course_ids) or t.teacher_open_course_ids = "ALL") @} @if(!isEmpty(noticeTitle)){ and t.notice_title =#noticeTitle# @@ -255,10 +255,10 @@ getValuesByQuery and find_in_set(t.teacher_open_course_notice_id,#teacherOpenCourseNoticeIdPlural#) @} @if(!isEmpty(schoolClassIds)){ - and t.school_class_ids =#schoolClassIds# + and (find_in_set(#schoolClassIds#, t.school_class_ids) or t.school_class_ids = "ALL") @} @if(!isEmpty(teacherOpenCourseIds)){ - and t.teacher_open_course_ids =#teacherOpenCourseIds# + and (find_in_set(#teacherOpenCourseIds#, t.teacher_open_course_ids) or t.teacher_open_course_ids = "ALL") @} @if(!isEmpty(noticeTitle)){ and t.notice_title =#noticeTitle# @@ -297,6 +297,62 @@ getValuesByQuery @} +getValuesByQueryNotWithPermission +=== + +* 根据不为空的参数进行查询 + + select t.* + from teacher_open_course_notice t + where 1=1 + @if(!isEmpty(teacherOpenCourseNoticeId)){ + and t.teacher_open_course_notice_id =#teacherOpenCourseNoticeId# + @} + @if(!isEmpty(teacherOpenCourseNoticeIdPlural)){ + and find_in_set(t.teacher_open_course_notice_id,#teacherOpenCourseNoticeIdPlural#) + @} + @if(!isEmpty(schoolClassIds)){ + and (find_in_set(#schoolClassIds#, t.school_class_ids) or t.school_class_ids = "ALL") + @} + @if(!isEmpty(teacherOpenCourseIds)){ + and (find_in_set(#teacherOpenCourseIds#, t.teacher_open_course_ids) or t.teacher_open_course_ids = "ALL") + @} + @if(!isEmpty(noticeTitle)){ + and t.notice_title =#noticeTitle# + @} + @if(!isEmpty(noticeContent)){ + and t.notice_content =#noticeContent# + @} + @if(!isEmpty(createTime)){ + and t.create_time =#createTime# + @} + @if(!isEmpty(createByTeacherId)){ + and t.create_by_teacher_id =#createByTeacherId# + @} + @if(!isEmpty(createByTeacherIdPlural)){ + and find_in_set(t.create_by_teacher_id,#createByTeacherIdPlural#) + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + @if(!isEmpty(delFlag)){ + and t.del_flag =#delFlag# + @} + @if(!isEmpty(studentId)){ + and find_in_set((select b.class_id + from student b left join school_class ba on ba.class_id = b.class_id + where b.student_status = 1 and ba.class_status = 1 and b.student_id = #studentId# ), t.school_class_ids) + @} + getClassByOpenCourseId ===