package com.salpa.subject.service.impl;

import com.github.pagehelper.PageHelper;
import com.salpa.common.utils.SecurityUtils;
import com.salpa.subject.domain.MonitorWarning;
import com.salpa.subject.mapper.WarningMapper;
import com.salpa.subject.service.WarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 告警管理业务层
 * @author zff
 */
@Service
public class WarningServiceImpl implements WarningService {

    @Autowired
    private WarningMapper warningMapper;

    /**
     * 获取告警列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<MonitorWarning> warningList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MonitorWarning> list = warningMapper.warningList();
        return list;
    }

    /**
     * 修改告警状态
     * @param id
     * @return
     */
    @Override
    public int updateStatus(Long id) {
        String userName = SecurityUtils.getLoginUser().getUser().getNickName();
        return warningMapper.updateStatus(id,userName);
    }
}
