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.GyeeuserinformationMapper;
import com.gyee.frame.model.auto.Gyeeuserinformation;
import com.gyee.frame.model.auto.GyeeuserinformationExample;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.SnowflakeIdWorker;

/**
 *  GyeeuserinformationService
 * @Title: GyeeuserinformationService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2020-04-16 15:54:30  
 **/
@Service
public class GyeeuserinformationService implements BaseService<Gyeeuserinformation, GyeeuserinformationExample>{
	@Autowired
	private GyeeuserinformationMapper gyeeuserinformationMapper;
	
      	   	      	      	      	      	      	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<Gyeeuserinformation> list(Tablepar tablepar,String name){
	        GyeeuserinformationExample testExample=new GyeeuserinformationExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andNameLike("%"+name+"%");
	        }

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

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

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

	
	@Override
	public int updateByExample(Gyeeuserinformation record, GyeeuserinformationExample example) {
		
		return gyeeuserinformationMapper.updateByExample(record, example);
	}

	@Override
	public List<Gyeeuserinformation> selectByExample(GyeeuserinformationExample example) {
		
		return gyeeuserinformationMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(GyeeuserinformationExample example) {
		
		return gyeeuserinformationMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(GyeeuserinformationExample example) {
		
		return gyeeuserinformationMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param gyeeuserinformation
	 * @return
	 */
	public int checkNameUnique(Gyeeuserinformation gyeeuserinformation){
		GyeeuserinformationExample example=new GyeeuserinformationExample();
		example.createCriteria().andNameEqualTo(gyeeuserinformation.getName());
		List<Gyeeuserinformation> list=gyeeuserinformationMapper.selectByExample(example);
		return list.size();
	}
	
	/**
	 * 
		 *@author:Li Miao
		 *
		 *@description: 通过userid查询用户信息
		 *
		 *@param:id
		 *
		 *@return:List<Gyeeuserinformation>
		 *
		 *@createTime:2020年4月16日
		 *
	 */
	public Gyeeuserinformation queryById(String userid){
		return gyeeuserinformationMapper.queryById(userid);
	}


}
