AlertServiceImpl.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.usthe.alert.service.impl;
  2. import com.usthe.alert.dao.AlertDao;
  3. import com.usthe.alert.pojo.entity.Alert;
  4. import com.usthe.alert.service.AlertService;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.data.domain.Page;
  8. import org.springframework.data.domain.PageRequest;
  9. import org.springframework.data.jpa.domain.Specification;
  10. import org.springframework.stereotype.Service;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import java.util.HashSet;
  13. /**
  14. * 告警信息服务实现
  15. * @author tom
  16. * @date 2021/12/10 15:39
  17. */
  18. @Service
  19. @Transactional(rollbackFor = Exception.class)
  20. @Slf4j
  21. public class AlertServiceImpl implements AlertService {
  22. @Autowired
  23. private AlertDao alertDao;
  24. @Override
  25. public void addAlert(Alert alert) throws RuntimeException {
  26. alertDao.save(alert);
  27. }
  28. @Override
  29. public Page<Alert> getAlerts(Specification<Alert> specification, PageRequest pageRequest) {
  30. return alertDao.findAll(specification, pageRequest);
  31. }
  32. @Override
  33. public void deleteAlerts(HashSet<Long> ids) {
  34. alertDao.deleteAlertsByIdIn(ids);
  35. }
  36. }