package com.gyee.frame.service;

import java.util.List;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.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.ShbraceletpointMapper;
import com.gyee.frame.model.auto.Shbraceletpoint;
import com.gyee.frame.model.auto.ShbraceletpointExample;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.SnowflakeIdWorker;

/**
 *  ShbraceletpointService
 * @Title: ShbraceletpointService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2020-05-20 19:07:48  
 **/
@Service
public class ShbraceletpointService implements BaseService<Shbraceletpoint, ShbraceletpointExample>{
	@Autowired
	private ShbraceletpointMapper shbraceletpointMapper;



		/**
		 * 查询集合
		 * @return
		 */
		public List<Shbraceletpoint> shbraceletpointList(Long beginDateTs,Long endDateTs){
			ShbraceletpointExample testExample=new ShbraceletpointExample();
			testExample.setOrderByClause("ts ASC");


				testExample.createCriteria().andTsGreaterThanOrEqualTo(beginDateTs).andTsLessThanOrEqualTo(endDateTs);
				List<Shbraceletpoint> shbraceletpointList = shbraceletpointMapper.selectByExample(testExample);


			return shbraceletpointList;
		}
	/**
	 * 分页查询
	 * @return
	 */
	 public PageInfo<Shbraceletpoint> list(Tablepar tablepar,String name){
	        ShbraceletpointExample testExample=new ShbraceletpointExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	//testExample.createCriteria().andTsLike("%"+name+"%");
	        }

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

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

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

	
	@Override
	public int updateByExample(Shbraceletpoint record, ShbraceletpointExample example) {
		
		return shbraceletpointMapper.updateByExample(record, example);
	}

	@Override
	public List<Shbraceletpoint> selectByExample(ShbraceletpointExample example) {
		
		return shbraceletpointMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ShbraceletpointExample example) {
		
		return shbraceletpointMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ShbraceletpointExample example) {
		
		return shbraceletpointMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param shbraceletpoint
	 * @return
	 */
	public int checkNameUnique(Shbraceletpoint shbraceletpoint){
		ShbraceletpointExample example=new ShbraceletpointExample();
		example.createCriteria().andTsEqualTo(shbraceletpoint.getTs());
		List<Shbraceletpoint> list=shbraceletpointMapper.selectByExample(example);
		return list.size();
	}


}
