package com.muyu.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.WarnStrategy;
import com.muyu.common.domain.req.WarnStrategyReq;
import com.muyu.common.domain.resp.WarnStrategyResp;
import com.muyu.server.mapper.WarnStrategyMapper;
import com.muyu.server.service.WarnStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 预警策略Service业务层处理
 *
 * @author muyu
 * @date 2024-09-20
 */
@Service
public class WarnStrategyServiceImpl
        extends ServiceImpl<WarnStrategyMapper, WarnStrategy>
        implements WarnStrategyService {
    @Autowired
    private WarnStrategyMapper warnStrategyMapper;

    /**
     * 精确查询预警策略
     *
     * @param id 预警策略主键
     * @return 预警策略
     */
    @Override
    public WarnStrategy selectWarnStrategyById(Long id)
    {
       return warnStrategyMapper.selectById(id);
    }


    /**
     * 查询预警策略列表
     *
     * @param warnStrategyReq 预警策略
     * @return 预警策略
     */
    @Override
    public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
    {
      return warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
    }

    @Override
    public Integer deleteWarnStrategy(Long id) {
        return warnStrategyMapper.deleteById(id);
    }


    /**
     * 修改
     */
    @Override
    public Integer updWarnStrategy(WarnStrategy warnStrategy){
        QueryWrapper<WarnStrategy> wrapper = new QueryWrapper<>(warnStrategy);
        return warnStrategyMapper.update(wrapper);
    }

    /**
     * 添加
     */
    @Override
    public Integer addWarnStrategy(WarnStrategy warnStrategy){
     return warnStrategyMapper.insert(warnStrategy);
    }



    /**
     * 根据车辆类型ID查询策略
     */
    @Override
    public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
        return warnStrategyMapper.selectListByCarType(carTypeId);
    }


}
