package com.muyu.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.WarnRule;
import com.muyu.common.domain.resp.WarnRuleResp;
import com.muyu.server.mapper.WarnRuleMapper;
import com.muyu.server.service.WarnRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;

/**
 * 预警规则Service业务层处理
 *
 * @author muyu
 * @date 2024-09-20
 */
@Service
public class WarnRuleServiceImpl
        extends ServiceImpl<WarnRuleMapper, WarnRule>
        implements WarnRuleService {
    @Autowired
    private WarnRuleMapper warnRuleMapper;

    /**
     * 精确查询预警规则
     *
     * @param id 预警规则主键
     * @return 预警规则
     */
    @Override
    public WarnRule selectWarnRuleById(Long id)
    {
        return warnRuleMapper.selectById(id);
    }


    /**
     * 查询预警规则列表
     *
     * @param
     * @return 预警规则
     */
    @Override
    public List<WarnRuleResp> selectWarnRuleRespList()
    {
        return warnRuleMapper.selectWarnRuleRespList();
    }

    @Override
    public Integer addWarnRule(WarnRule warnRule) {
        return warnRuleMapper.insert(warnRule);
    }

    @Override
    public Integer updWarnRule(WarnRule warnRule) {
        LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
        return warnRuleMapper.update(queryWrapper);
    }

    @Override
    public List<WarnRuleResp> selectListByStrategyId(Long strategyId) {
        return warnRuleMapper.selectListByStrategyId(strategyId);
    }


}
