package com.gyee.frame.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Arrays;

import com.gyee.frame.model.auto.*;
import com.gyee.frame.model.enumeration.Messagetype;
import com.gyee.frame.netty.websocket.util.SocketToolService;
import com.gyee.frame.util.DateUtils;
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.UserauthorityMapper;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.SnowflakeIdWorker;

/**
 *  UserauthorityService
 * @Title: UserauthorityService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2020-03-30 10:51:16  
 **/
@Service
public class UserauthorityService extends SocketToolService implements BaseService<Userauthority, UserauthorityExample> {
	@Autowired
	private UserauthorityMapper userauthorityMapper;
	
      	      	      	      	
	/**
	 * 分页查询
	 * @return
	 */
	 public PageInfo<Userauthority> list(Tablepar tablepar,String name){
	        UserauthorityExample testExample=new UserauthorityExample();
	        testExample.setOrderByClause(" ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andPowerstationidLike("%"+name+"%");
	        }

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




	/**
	 *
	 *@author:Wang Jiawen
	 *
	 *@description: 分配权限查询
	 *
	 *@date:2020年3月30日
	 *
	 */

	public List<Userauthority> selectUserauthorityListByUserid(String userid) throws ParseException {
		UserauthorityExample testExample=new UserauthorityExample();
		testExample.setOrderByClause("id ASC");
		testExample.createCriteria().andUseridEqualTo(userid);
		List<Userauthority> userauthorityList = userauthorityMapper.selectByExample(testExample);
		return userauthorityList;
	}






	@Override
	public int deleteByPrimaryKey(String id) {
		return 0;
	}

	/**
	 * 添加
	 */
	@Override
	public int insertSelective(Userauthority record) {
		return userauthorityMapper.insertSelective(record);
	}

	@Override
	public Userauthority selectByPrimaryKey(String id) {
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(Userauthority record) {
		return 0;
	}


	@Override
	public int updateByExampleSelective(Userauthority record, UserauthorityExample example) {
		
		return userauthorityMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Userauthority record, UserauthorityExample example) {
		
		return userauthorityMapper.updateByExample(record, example);
	}

	@Override
	public List<Userauthority> selectByExample(UserauthorityExample example) {
		
		return userauthorityMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(UserauthorityExample example) {
		
		return userauthorityMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(UserauthorityExample example) {
		
		return userauthorityMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param userauthority
	 * @return
	 */
	public int checkNameUnique(Userauthority userauthority){
		UserauthorityExample example=new UserauthorityExample();
		example.createCriteria().andPowerstationidEqualTo(userauthority.getPowerstationid());
		List<Userauthority> list=userauthorityMapper.selectByExample(example);
		return list.size();
	}


}
