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.ShbrUserMapper;
import com.gyee.frame.model.auto.ShbrUser;
import com.gyee.frame.model.auto.ShbrUserExample;
import com.gyee.frame.util.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ShbrUserService implements BaseService<ShbrUser, ShbrUserExample> {
	@Resource
	private ShbrUserMapper shbrUserMapper;
	

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<Integer> lista=Convert.toIntArrayList(ids);
			ShbrUserExample example=new ShbrUserExample();
			example.createCriteria().andIdIn(lista);
			return shbrUserMapper.deleteByExample(example);
			
				
	}
	

	@Override
	public ShbrUser selectByPrimaryKey(String id) {

			return shbrUserMapper.selectByPrimaryKey(Integer.valueOf(id));

	}


	@Override
	public int updateByPrimaryKeySelective(ShbrUser record) {
		return shbrUserMapper.updateByPrimaryKeySelective(record);
	}

	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(ShbrUser record) {

		return shbrUserMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(ShbrUser record, ShbrUserExample example) {
		
		return shbrUserMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(ShbrUser record, ShbrUserExample example) {
		
		return shbrUserMapper.updateByExample(record, example);
	}

	@Override
	public List<ShbrUser> selectByExample(ShbrUserExample example) {
		
		return shbrUserMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ShbrUserExample example) {
		
		return shbrUserMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ShbrUserExample example) {
		
		return shbrUserMapper.deleteByExample(example);
	}

	//通过用户名称获得用户信息
	public ShbrUser findShbrUserByName(String name) {

		ShbrUser po=new ShbrUser();

		if(StringUtils.notEmp(name))
		{
			ShbrUserExample example=new ShbrUserExample();

			ShbrUserExample.Criteria criteria =example.createCriteria();

			criteria.andUsernameEqualTo(name);
			List<ShbrUser>  list= shbrUserMapper.selectByExample(example);

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

		return po;

	}
}
