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 5f67dafad8ff537499b59ce8eb4067b45b45d1a7..89eec57a7752ea5f52a7c7bc01068d14b51fb6f1 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 32ce288301fdc01e908e50aa8d9cabce88eb5b55..1251f907eaddb1e9d0cc0d9726929e18502b109b 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 abf29355b3b4895d8ff9e7876c1bd2f4d832e74e..0d346fc42c1cbed4b79540863791525f2c2acb77 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(); + } }