package com.bocloud.ims.service.resource;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.ims.interfaces.resource.AlarmThresholdService;
import com.bocloud.ims.repository.resource.AlarmThresholdRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 告警阈值设置service实现
 *
 * @author wangyu
 * @version 1.0
 * @since 2018年4月18日
 */
@Service("alarmThresholdService")
public class AlarmThresholdServiceImpl implements AlarmThresholdService {

    private static final Logger logger = LoggerFactory.getLogger(AlarmThresholdServiceImpl.class);
    @Autowired
    private AlarmThresholdRepository alarmThresholdRepository;

    @Override
    public BocloudResult remove(Long target, String catalog) {
        try {
            boolean flag = alarmThresholdRepository.removeByTarget(target, catalog);
            return flag ? new BocloudResult<>(true, "删除成功") : new BocloudResult<>(false, "删除失败");
        } catch (Exception e) {
            logger.error("Get error message:", e);
            return new BocloudResult<>(false, "删除失败:" + e.getMessage());
        }
    }

}
