package com.gyee.frame.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.WindTurbineTestingPointDiMapper;
import com.gyee.frame.model.auto.WindTurbineTestingPointDi;
import com.gyee.frame.model.auto.WindTurbineTestingPointDiExample;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.SnowflakeIdWorker;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 风机DI测点 WindTurbineTestingPointDiService
 * @Title: WindTurbineTestingPointDiService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2019-12-31 14:58:09  
 **/
@Service
public class WindTurbineTestingPointDiService implements BaseService<WindTurbineTestingPointDi, WindTurbineTestingPointDiExample>{
	@Resource
	private WindTurbineTestingPointDiMapper windTurbineTestingPointDiMapper;
	
      	   	      	      	      	      	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param tablepar
	 * @param name
	 * @return
	 */
	 public PageInfo<WindTurbineTestingPointDi> list(Tablepar tablepar,String name){
	        WindTurbineTestingPointDiExample testExample=new WindTurbineTestingPointDiExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andCodeLike("%"+name+"%");
	        }

	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<WindTurbineTestingPointDi> list= windTurbineTestingPointDiMapper.selectByExample(testExample);
	        PageInfo<WindTurbineTestingPointDi> pageInfo = new PageInfo<WindTurbineTestingPointDi>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			WindTurbineTestingPointDiExample example=new WindTurbineTestingPointDiExample();
			example.createCriteria().andIdIn(lista);
			return windTurbineTestingPointDiMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public WindTurbineTestingPointDi selectByPrimaryKey(String id) {
				
			return windTurbineTestingPointDiMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(WindTurbineTestingPointDi record) {
		return windTurbineTestingPointDiMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(WindTurbineTestingPointDi record) {
				
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return windTurbineTestingPointDiMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(WindTurbineTestingPointDi record, WindTurbineTestingPointDiExample example) {
		
		return windTurbineTestingPointDiMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(WindTurbineTestingPointDi record, WindTurbineTestingPointDiExample example) {
		
		return windTurbineTestingPointDiMapper.updateByExample(record, example);
	}

	@Override
	public List<WindTurbineTestingPointDi> selectByExample(WindTurbineTestingPointDiExample example) {
		
		return windTurbineTestingPointDiMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindTurbineTestingPointDiExample example) {
		
		return windTurbineTestingPointDiMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindTurbineTestingPointDiExample example) {
		
		return windTurbineTestingPointDiMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param windTurbineTestingPointDi
	 * @return
	 */
	public int checkNameUnique(WindTurbineTestingPointDi windTurbineTestingPointDi){
		WindTurbineTestingPointDiExample example=new WindTurbineTestingPointDiExample();
		example.createCriteria().andCodeEqualTo(windTurbineTestingPointDi.getCode());
		List<WindTurbineTestingPointDi> list=windTurbineTestingPointDiMapper.selectByExample(example);
		return list.size();
	}


}
