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.WindPowerstationTestingPointMapper;
import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
import com.gyee.frame.model.auto.WindPowerstationTestingPointExample;
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;

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

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

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			WindPowerstationTestingPointExample example=new WindPowerstationTestingPointExample();
			example.createCriteria().andCodeIn(lista);
			return windPowerstationTestingPointMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public WindPowerstationTestingPoint selectByPrimaryKey(String id) {
				
			return windPowerstationTestingPointMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(WindPowerstationTestingPoint record) {
		return windPowerstationTestingPointMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(WindPowerstationTestingPoint record) {
				
		//添加雪花主键id
		record.setCode(SnowflakeIdWorker.getUUID());
			
				
		return windPowerstationTestingPointMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(WindPowerstationTestingPoint record, WindPowerstationTestingPointExample example) {
		
		return windPowerstationTestingPointMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(WindPowerstationTestingPoint record, WindPowerstationTestingPointExample example) {
		
		return windPowerstationTestingPointMapper.updateByExample(record, example);
	}

	@Override
	public List<WindPowerstationTestingPoint> selectByExample(WindPowerstationTestingPointExample example) {
		
		return windPowerstationTestingPointMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindPowerstationTestingPointExample example) {
		
		return windPowerstationTestingPointMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindPowerstationTestingPointExample example) {
		
		return windPowerstationTestingPointMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param windPowerstationTestingPoint
	 * @return
	 */
	public int checkNameUnique(WindPowerstationTestingPoint windPowerstationTestingPoint){
		WindPowerstationTestingPointExample example=new WindPowerstationTestingPointExample();
		example.createCriteria().andCodeEqualTo(windPowerstationTestingPoint.getCode());
		List<WindPowerstationTestingPoint> list=windPowerstationTestingPointMapper.selectByExample(example);
		return list.size();
	}


}
