package com.gyee.frame.service;

import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.dataSources.DataSource;
import com.gyee.frame.common.dataSources.DataSourceType;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.WindturbineSqlMapper;
import com.gyee.frame.model.auto.WindturbineSql;
import com.gyee.frame.model.auto.WindturbineSqlExample;
import com.gyee.frame.util.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class WindturbineSqlService implements BaseService<WindturbineSql, WindturbineSqlExample> {
	@Resource
	private WindturbineSqlMapper windturbineSqlMapper;
	

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<Double> lista=Convert.toDoubleArrayList(ids);
			WindturbineSqlExample example=new WindturbineSqlExample();
			example.createCriteria().andIdIn(lista);
			return windturbineSqlMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public WindturbineSql selectByPrimaryKey(String id) {
				
			return windturbineSqlMapper.selectByPrimaryKey(Double.valueOf(id));
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(WindturbineSql record) {
		return windturbineSqlMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(WindturbineSql record) {
				
			
				
		return windturbineSqlMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(WindturbineSql record, WindturbineSqlExample example) {
		
		return windturbineSqlMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(WindturbineSql record, WindturbineSqlExample example) {
		
		return windturbineSqlMapper.updateByExample(record, example);
	}

	@Override
	public List<WindturbineSql> selectByExample(WindturbineSqlExample example) {
		
		return windturbineSqlMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindturbineSqlExample example) {
		
		return windturbineSqlMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindturbineSqlExample example) {
		
		return windturbineSqlMapper.deleteByExample(example);
	}

	@DataSource(value = DataSourceType.TICKET)
	public WindturbineSql findWindturbineById(String wtnum) {


		WindturbineSql po=new WindturbineSql();

		if(StringUtils.notEmp(wtnum) )
		{
			WindturbineSqlExample example=new WindturbineSqlExample();


			WindturbineSqlExample.Criteria criteria =example.createCriteria();

			criteria.andWtnumEqualTo(Double.valueOf(wtnum));

			List<WindturbineSql> list= windturbineSqlMapper.selectByExample(example);

			if(!list.isEmpty())
			{
				po=list.get(0);

			}

		}

		return po;

	}
}
