package com.gyee.frame.service.health;

import com.github.pagehelper.PageInfo;
import com.gyee.frame.model.auto.P3DeviceFault;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.service.P3DeviceFaultService;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class FaultKnowledgeService {

    @Resource
    private P3DeviceFaultService p3DeviceFaultService;


    private final int digit = 2;


    public PageInfo<P3DeviceFault> findP3DeviceFaultList(Tablepar tablepar, String name, String halttype, String faultlevel) {


        PageInfo<P3DeviceFault> pageInfo = new PageInfo<>();


        pageInfo = p3DeviceFaultService.findP3DeviceFaultList(tablepar, name, halttype, faultlevel);

        return pageInfo;

    }


    public P3DeviceFault findP3DeviceFaultById(String id) {


       P3DeviceFault  po = new P3DeviceFault();

        po = p3DeviceFaultService.selectByPrimaryKey(id);

        return po;

    }

    public int updateP3DeviceFault(P3DeviceFault po) {

        int result =-1;
        if(StringUtils.notEmp(po) && StringUtils.notEmp(po.getId()))
        {
            result =p3DeviceFaultService.updateByPrimaryKeySelective(po);
        }
        return result;

    }

    public int insertP3DeviceFault(P3DeviceFault po) {

        int result =-1;
        if(StringUtils.notEmp(po) )
        {
             result = p3DeviceFaultService.insertSelective(po);
        }


        return result;

    }

    public int deleteP3DeviceFault(String id) {

        int result =-1;
        if(StringUtils.notEmp(id))
        {
            result =p3DeviceFaultService.deleteByPrimaryKey(id);
        }
        return result;

    }
}
