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.WindPowerStationTestingPoint2Mapper;
import com.gyee.frame.model.auto.WindPowerStationTestingPoint2;
import com.gyee.frame.model.auto.WindPowerStationTestingPoint2Example;
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<WindPowerStationTestingPoint2, WindPowerStationTestingPoint2Example>{
	@Resource
	private WindPowerStationTestingPoint2Mapper windPowerStationTestingPoint2Mapper;
	
      	   	      	      	      	      	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param tablepar
	 * @param name
	 * @return
	 */
	 public PageInfo<WindPowerStationTestingPoint2> list(Tablepar tablepar,String name){
	        WindPowerStationTestingPoint2Example testExample=new WindPowerStationTestingPoint2Example();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andCodeLike("%"+name+"%");
	        }

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

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

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

	
	@Override
	public int updateByExample(WindPowerStationTestingPoint2 record, WindPowerStationTestingPoint2Example example) {
		
		return windPowerStationTestingPoint2Mapper.updateByExample(record, example);
	}

	@Override
	public List<WindPowerStationTestingPoint2> selectByExample(WindPowerStationTestingPoint2Example example) {
		
		return windPowerStationTestingPoint2Mapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindPowerStationTestingPoint2Example example) {
		
		return windPowerStationTestingPoint2Mapper.countByExample(example);
	}

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


}
