package com.muyu.enterprise.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.domain.Result;

import com.muyu.domain.*;
import com.muyu.domain.vo.RuleVo;
import com.muyu.enterprise.mapper.RuleMapper;
import com.muyu.enterprise.service.RuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：ChenYan
 * @Project：2112-car-cloud-server
 * @Package：com.muyu.fault.service
 * @Filename：RuleServiceImpl
 * @Description TODO
 * @Date：2024/9/21 18:49
 */
@Service
public class RuleServiceImpl extends ServiceImpl<RuleMapper, Rule> implements RuleService {


    @Autowired
    private RuleMapper ruleMapper;

    /**
     *
     * @param fault 车辆故障管理主键
     * @return  fault
     */
    @Override
    public List<Rule> pageQuery(Rule fault) {
        LambdaQueryWrapper<Rule> queryWrapper = new LambdaQueryWrapper<>();
        if (fault.getRuleValue()!=null) {
            queryWrapper.like(Rule::getRuleValue, fault.getRuleValue());
        }
        return this.list(queryWrapper);
    }

    @Override
    public List<RuleVo> pageQueryRule(RuleVo fault) {
        List<RuleVo>list=ruleMapper.pageQueryRule(fault);
        return list;
    }

    /**
     * 下拉框
     * @param fault
     * @return
     */
    @Override
    public Result<List<Custom>> pageQueryList(Custom fault) {
        List<Custom>list=ruleMapper.pageQueryList(fault);
        return Result.success(list,"成功");
    }

    @Override
    public Result<List<Vehicle>> pageQueryCar(Vehicle fault) {
        List<Vehicle>list=ruleMapper.pageQueryCar(fault);
        return Result.success(list,"成功");
    }

    @Override
    public Result<List<Type>> pageQueryType(Type fault) {
        List<Type>list=ruleMapper.pageQueryType(fault);
        return Result.success(list,"成功");
    }

    @Override
    public Result<List<MessageValue>> pageQueryMessageValue(MessageValue fault) {
        List<MessageValue>list=ruleMapper.pageQueryMessageValue(fault);
        return Result.success(list,"成功");
    }


    /***
     * 车辆故障管理insertFault
     * @param faultInfo
     * @return
     */
    @Override
    public int insertFault(Rule faultInfo) {
        int i = ruleMapper.insertFault(faultInfo);
        return i;
    }


    /**
     * 车辆故障管理updateFault
     * @param faultInfo
     * @return
     */
    @Override
    public int updateFault(Rule faultInfo) {
        int i = ruleMapper.updateFault(faultInfo);
        return i;
    }


}
