AlertServiceImpl.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. import java.util.List;
  14. /**
  15. * 告警信息服务实现
  16. * @author tom
  17. * @date 2021/12/10 15:39
  18. */
  19. @Service
  20. @Transactional(rollbackFor = Exception.class)
  21. @Slf4j
  22. public class AlertServiceImpl implements AlertService {
  23. @Autowired
  24. private AlertDao alertDao;
  25. @Override
  26. public void addAlert(Alert alert) throws RuntimeException {
  27. alertDao.save(alert);
  28. }
  29. @Override
  30. public Page<Alert> getAlerts(Specification<Alert> specification, PageRequest pageRequest) {
  31. return alertDao.findAll(specification, pageRequest);
  32. }
  33. @Override
  34. public void deleteAlerts(HashSet<Long> ids) {
  35. alertDao.deleteAlertsByIdIn(ids);
  36. }
  37. @Override
  38. public void editAlertStatus(Byte status, List<Long> ids) {
  39. alertDao.updateAlertsStatus(status, ids);
  40. }
  41. }