org.openea.eap.module.system.service.notice.NoticeServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eap-module-system-biz Show documentation
Show all versions of eap-module-system-biz Show documentation
system 模块下,我们放通用业务,支撑上层的核心业务。
例如说:用户、部门、权限、数据字典等等
The newest version!
package org.openea.eap.module.system.service.notice;
import org.openea.eap.framework.common.pojo.PageResult;
import org.openea.eap.framework.common.util.object.BeanUtils;
import org.openea.eap.module.system.controller.admin.notice.vo.NoticePageReqVO;
import org.openea.eap.module.system.controller.admin.notice.vo.NoticeSaveReqVO;
import org.openea.eap.module.system.dal.dataobject.notice.NoticeDO;
import org.openea.eap.module.system.dal.mysql.notice.NoticeMapper;
import com.google.common.annotations.VisibleForTesting;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import static org.openea.eap.framework.common.exception.util.ServiceExceptionUtil.exception;
import static org.openea.eap.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND;
/**
* 通知公告 Service 实现类
*
*/
@Service
public class NoticeServiceImpl implements NoticeService {
@Resource
private NoticeMapper noticeMapper;
@Override
public Long createNotice(NoticeSaveReqVO createReqVO) {
NoticeDO notice = BeanUtils.toBean(createReqVO, NoticeDO.class);
noticeMapper.insert(notice);
return notice.getId();
}
@Override
public void updateNotice(NoticeSaveReqVO updateReqVO) {
// 校验是否存在
validateNoticeExists(updateReqVO.getId());
// 更新通知公告
NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class);
noticeMapper.updateById(updateObj);
}
@Override
public void deleteNotice(Long id) {
// 校验是否存在
validateNoticeExists(id);
// 删除通知公告
noticeMapper.deleteById(id);
}
@Override
public PageResult getNoticePage(NoticePageReqVO reqVO) {
return noticeMapper.selectPage(reqVO);
}
@Override
public NoticeDO getNotice(Long id) {
return noticeMapper.selectById(id);
}
@VisibleForTesting
public void validateNoticeExists(Long id) {
if (id == null) {
return;
}
NoticeDO notice = noticeMapper.selectById(id);
if (notice == null) {
throw exception(NOTICE_NOT_FOUND);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy