package com.gyee.frame.service;

import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.ShbraceletUserMapper;
import com.gyee.frame.model.auto.ShbraceletUser;
import com.gyee.frame.model.auto.ShbraceletUserExample;
import com.gyee.frame.util.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ShbraceletUserService implements BaseService<ShbraceletUser, ShbraceletUserExample> {
	@Resource
	private ShbraceletUserMapper shbraceletUserMapper;
	

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<Integer> lista=Convert.toIntArrayList(ids);
			ShbraceletUserExample example=new ShbraceletUserExample();
			example.createCriteria().andIdIn(lista);
			return shbraceletUserMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public ShbraceletUser selectByPrimaryKey(String id) {
				
			return shbraceletUserMapper.selectByPrimaryKey(Integer.valueOf(id));
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(ShbraceletUser record) {
		return shbraceletUserMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(ShbraceletUser record) {
				

				
		return shbraceletUserMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(ShbraceletUser record, ShbraceletUserExample example) {
		
		return shbraceletUserMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(ShbraceletUser record, ShbraceletUserExample example) {
		
		return shbraceletUserMapper.updateByExample(record, example);
	}

	@Override
	public List<ShbraceletUser> selectByExample(ShbraceletUserExample example) {
		
		return shbraceletUserMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ShbraceletUserExample example) {
		
		return shbraceletUserMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ShbraceletUserExample example) {
		
		return shbraceletUserMapper.deleteByExample(example);
	}


	//通过用户名称获得相应手环设备信息
	public ShbraceletUser findShbraceletUserById(int userId) {

		ShbraceletUser po=new ShbraceletUser();

		if(StringUtils.notEmp(userId))
		{
			ShbraceletUserExample example=new ShbraceletUserExample();

			ShbraceletUserExample.Criteria criteria =example.createCriteria();

			criteria.andUseridEqualTo(userId);
			List<ShbraceletUser>  list= shbraceletUserMapper.selectByExample(example);

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

		return po;

	}
}
