|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.system.service.notice;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
|
|
@@ -7,9 +8,10 @@ import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper;
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import jakarta.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND;
|
|
|
@@ -49,6 +51,14 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
noticeMapper.deleteById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void deleteNoticeList(List<Long> ids) {
|
|
|
+ // 校验是否存在
|
|
|
+ validateNoticesExists(ids);
|
|
|
+ // 批量删除通知公告
|
|
|
+ noticeMapper.deleteByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) {
|
|
|
return noticeMapper.selectPage(reqVO);
|
|
|
@@ -70,4 +80,15 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void validateNoticesExists(List<Long> ids) {
|
|
|
+ if (CollUtil.isEmpty(ids)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 校验存在
|
|
|
+ List<NoticeDO> notices = noticeMapper.selectByIds(ids);
|
|
|
+ if (CollUtil.isEmpty(notices) || notices.size() != ids.size()) {
|
|
|
+ throw exception(NOTICE_NOT_FOUND);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|