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.WindTurbineTestingPointAiMapper;
import com.gyee.frame.model.auto.WindTurbineTestingPointAi;
import com.gyee.frame.model.auto.WindTurbineTestingPointAiExample;
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;

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

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

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

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

	
	@Override
	public int updateByExample(WindTurbineTestingPointAi record, WindTurbineTestingPointAiExample example) {
		
		return windTurbineTestingPointAiMapper.updateByExample(record, example);
	}

	@Override
	public List<WindTurbineTestingPointAi> selectByExample(WindTurbineTestingPointAiExample example) {
		
		return windTurbineTestingPointAiMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindTurbineTestingPointAiExample example) {
		
		return windTurbineTestingPointAiMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindTurbineTestingPointAiExample example) {
		
		return windTurbineTestingPointAiMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param windTurbineTestingPointAi
	 * @return
	 */
	public int checkNameUnique(WindTurbineTestingPointAi windTurbineTestingPointAi){
		WindTurbineTestingPointAiExample example=new WindTurbineTestingPointAiExample();
		example.createCriteria().andCodeEqualTo(windTurbineTestingPointAi.getCode());
		List<WindTurbineTestingPointAi> list=windTurbineTestingPointAiMapper.selectByExample(example);
		return list.size();
	}


}
