| | |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| | |
| | | @Service |
| | | public class NoticeServiceImpl implements NoticeService { |
| | | |
| | | /** 附件关联的业务记录类型 */ |
| | | private static final String RECORD_TYPE = "notice"; |
| | | /** 附件应用用途 */ |
| | | private static final String APPLICATION = "file"; |
| | | |
| | | @Resource |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Override |
| | | public Long createNotice(NoticeSaveReqVO createReqVO) { |
| | | NoticeDO notice = BeanUtils.toBean(createReqVO, NoticeDO.class); |
| | | noticeMapper.insert(notice); |
| | | storageAttachmentApi.bindAttachments(APPLICATION, RECORD_TYPE, notice.getId(), createReqVO.getBlobIds()); |
| | | return notice.getId(); |
| | | } |
| | | |
| | |
| | | // 更新通知公告 |
| | | NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class); |
| | | noticeMapper.updateById(updateObj); |
| | | storageAttachmentApi.updateAttachments(APPLICATION, RECORD_TYPE, updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteNotice(Long id) { |
| | | // 校验是否存在 |
| | | validateNoticeExists(id); |
| | | // 删除通知公告 |
| | | // 删除通知公告及其附件关联 |
| | | noticeMapper.deleteById(id); |
| | | storageAttachmentApi.deleteAttachmentsByRecord(RECORD_TYPE, id); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteNoticeList(List<Long> ids) { |
| | | noticeMapper.deleteByIds(ids); |
| | | for (Long id : ids) { |
| | | storageAttachmentApi.deleteAttachmentsByRecord(RECORD_TYPE, id); |
| | | } |
| | | } |
| | | |
| | | @Override |