From b03a76077e45fb3a9244e96af22587a2d38da16e Mon Sep 17 00:00:00 2001 From: czk Date: Thu, 28 Oct 2021 09:17:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E3=80=90=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E4=BF=9D=E5=AD=98=E6=97=B6=E8=8E=B7=E5=8F=96=E8=87=AA?= =?UTF-8?q?=E5=A2=9EID=E3=80=91=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E6=B6=89=E5=8F=8A=E8=8E=B7=E5=8F=96=E8=87=AA=E5=A2=9EID?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NoticeController.java | 7 +++---- .../service/NoticeService.java | 10 ++++++++++ .../service/impl/NoticeServiceImpl.java | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mobile_education_platform/controller/NoticeController.java b/src/main/java/com/mobile_education_platform/controller/NoticeController.java index 5f67daf..89eec57 100644 --- a/src/main/java/com/mobile_education_platform/controller/NoticeController.java +++ b/src/main/java/com/mobile_education_platform/controller/NoticeController.java @@ -3,9 +3,7 @@ package com.mobile_education_platform.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hazelcast.internal.json.Json; import com.mobile_education_platform.common.R; import com.mobile_education_platform.pojo.*; import com.mobile_education_platform.pojo.Class; @@ -16,7 +14,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.apache.commons.collections.map.LinkedMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -165,9 +162,11 @@ public class NoticeController { if (!saveNotice) { return R.error("保存通知失败!请检查是否有误!"); } + //对刚保存的通知,获取生成的ID + String noticeId = noticeService.getAddNoticeId(notice); for(String classId:classIds){ ClassNotice classNotice = new ClassNotice(); - classNotice.setNoticeId(notice.getId()); + classNotice.setNoticeId(noticeId); classNotice.setClassId(classId); boolean saveClassNotice = classNoticeService.save(classNotice); if (!saveClassNotice) { diff --git a/src/main/java/com/mobile_education_platform/service/NoticeService.java b/src/main/java/com/mobile_education_platform/service/NoticeService.java index 32ce288..1251f90 100644 --- a/src/main/java/com/mobile_education_platform/service/NoticeService.java +++ b/src/main/java/com/mobile_education_platform/service/NoticeService.java @@ -48,4 +48,14 @@ public interface NoticeService extends IService { * @throws IOException */ String sendSubscribeMessage(WxMsgVO vo) throws IOException; + + /** + * 功能: 刚保存的通知生成ID后,对ID进行获取 + * @author: ChenZiKang + * @Created: 2021/10/28 9:09 + * @param notice 通知 + * @return 通知ID + */ + String getAddNoticeId(Notice notice); + } diff --git a/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java index abf2935..0d346fc 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java @@ -128,4 +128,22 @@ public class NoticeServiceImpl extends ServiceImpl impleme return info; } + + /** + * 功能: 刚保存的通知生成ID后,对ID进行获取 + * @author: ChenZiKang + * @Created: 2021/10/28 9:09 + * @param notice 通知 + * @return 通知ID + */ + @Override + public String getAddNoticeId(Notice notice) { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("title",notice.getTitle()); + queryWrapper.eq("content",notice.getContent()); + queryWrapper.eq("promulgator_id",notice.getPromulgatorId()); + queryWrapper.eq("is_deleted",notice.getIsDeleted()); + Notice result = baseMapper.selectOne(queryWrapper); + return result.getId(); + } } -- Gitee