lideyin 6 vuotta sitten
vanhempi
commit
42cb08bae9

+ 7 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/NoticeController.java

@@ -54,6 +54,13 @@ public class NoticeController extends ControllerSupport {
         return resultPageInfo;
     }
 
+    @ApiOperation(value = "修改通知信息")
+    @PostMapping("disposeNotice")
+    public void disposeNotice() {
+        noticeService.disposePublishingUserNotice();
+    }
+
+
     @ApiOperation(value = "添加新通知")
     @PostMapping("addNotice")
     public void addNotice(@Validated @RequestBody AddNoticeDomain addNoticeDomain) {

+ 2 - 1
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/UserNoticeRepo.java

@@ -17,9 +17,10 @@ public interface UserNoticeRepo extends JpaRepository<UserNoticeEntity, Long>,
 
     List<UserNoticeEntity> findByRootOrgIdAndUserTypeAndUserIdAndHasReadOrderByCreationTimeDesc(Long rootOrgId,UserType userType,Long userId,Boolean hasRead);
 
+    @Transactional
     @Modifying
     @Query(value = "update EC_E_USER_NOTICE set has_read = 1 where notice_id in ?1 and user_type = ?2 and user_id = ?3",nativeQuery = true)
-    int updateNoticeReadStatus(String noticeId, UserType userType, Long userId);
+    int updateNoticeReadStatus(List<Long> noticeId, String userType, Long userId);
 
     @Transactional
     @Modifying

+ 20 - 14
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/NoticeServiceImpl.java

@@ -98,7 +98,13 @@ public class NoticeServiceImpl implements NoticeService {
 
     @Override
     public int updateNoticeReadStatus(String noticeId, UserType userType, Long userId) {
-        return userNoticeRepo.updateNoticeReadStatus(noticeId, userType, userId);
+        List<Long> noticeIdList = new ArrayList<>();
+        if (noticeId.indexOf(",")>-1){
+            noticeIdList=Arrays.asList(noticeId.split(",")).stream().map(p->Long.parseLong(p)).collect(Collectors.toList());
+        }else {
+            noticeIdList=Arrays.asList(noticeId).stream().map(p->Long.parseLong(p)).collect(Collectors.toList());
+        }
+        return userNoticeRepo.updateNoticeReadStatus(noticeIdList, userType.toString(), userId);
     }
 
     @Override
@@ -312,10 +318,10 @@ public class NoticeServiceImpl implements NoticeService {
 
         //如果起始id和方法返回的下次查询id相同,说明数据已经取完,否则继续查询
         if (startUserId.equals(nextId)) {
-            finishNoticePublishSchedule(rootOrgId, noticeId, ruleType, publishSchedule, limitStudentIdList);
+            finishNoticePublishSchedule(publishSchedule);
         } else {
-            updateNoticePublishSchedule(publishSchedule, maxUserId);
-            batchAddUserNotice(rootOrgId, noticeId, rowNumber, startUserId, ruleType, ruleList, publishSchedule);
+            saveUserNoticeAndUpdatePublishSchedule(rootOrgId, noticeId, ruleType, publishSchedule, limitStudentIdList, maxUserId);
+            batchAddUserNotice(rootOrgId, noticeId, rowNumber, nextId, ruleType, ruleList, publishSchedule);
         }
     }
 
@@ -325,7 +331,15 @@ public class NoticeServiceImpl implements NoticeService {
      * @param publishSchedule
      * @param maxUserId
      */
-    private void updateNoticePublishSchedule(NoticePublishScheduleEntity publishSchedule, Long maxUserId) {
+    @Transactional
+    void saveUserNoticeAndUpdatePublishSchedule(Long rootOrgId, Long noticeId, NoticeReceiverRuleType ruleType, NoticePublishScheduleEntity publishSchedule, List<Long> limitStudentIdList, Long maxUserId) {
+        //保存并更新发布状态为发布完成
+        List<UserNoticeEntity> userNoticeList = new ArrayList<>();
+        for (Long userId : limitStudentIdList) {
+            UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, userId, noticeId, ruleType);
+            userNoticeList.add(userNotice);
+        }
+        userNoticeRepo.saveAll(userNoticeList);
         publishSchedule.setMaxStudentId(maxUserId);
         noticePublishScheduleRepo.save(publishSchedule);
     }
@@ -339,15 +353,7 @@ public class NoticeServiceImpl implements NoticeService {
      * @param publishSchedule
      * @param limitStudentIdList
      */
-    @Transactional
-    public void finishNoticePublishSchedule(Long rootOrgId, Long noticeId, NoticeReceiverRuleType ruleType, NoticePublishScheduleEntity publishSchedule, List<Long> limitStudentIdList) {
-        //保存并更新发布状态为发布完成
-        List<UserNoticeEntity> userNoticeList = new ArrayList<>();
-        for (Long userId : limitStudentIdList) {
-            UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, userId, noticeId, ruleType);
-            userNoticeList.add(userNotice);
-        }
-        userNoticeRepo.saveAll(userNoticeList);
+    private void finishNoticePublishSchedule( NoticePublishScheduleEntity publishSchedule) {
         publishSchedule.setPublishStatus(NoticePublishStatus.PUBLISHED);
         noticePublishScheduleRepo.save(publishSchedule);
     }