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.ReportdetailMapper;
import com.gyee.frame.model.auto.Reportdetail;
import com.gyee.frame.model.auto.ReportdetailExample;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.SnowflakeIdWorker;

/**
 *  ReportdetailService
 * @Title: ReportdetailService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2020-03-02 15:04:24  
 **/
@Service
public class ReportdetailService implements BaseService<Reportdetail, ReportdetailExample>{
	@Autowired
	private ReportdetailMapper reportdetailMapper;
	
      	   	      	      	      	      	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<Reportdetail> list(Tablepar tablepar,String name){
	        ReportdetailExample testExample=new ReportdetailExample();
	        testExample.setOrderByClause("detailreportid ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andAreanameLike("%"+name+"%");
	        }

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

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			ReportdetailExample example=new ReportdetailExample();
			example.createCriteria().andDetailreportidIn(lista);
			return reportdetailMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public Reportdetail selectByPrimaryKey(String id) {
				
			return reportdetailMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(Reportdetail record) {
		return reportdetailMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(Reportdetail record) {
				
		//添加雪花主键id
		record.setDetailreportid(SnowflakeIdWorker.getUUID());
			
				
		return reportdetailMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Reportdetail record, ReportdetailExample example) {
		
		return reportdetailMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Reportdetail record, ReportdetailExample example) {
		
		return reportdetailMapper.updateByExample(record, example);
	}

	@Override
	public List<Reportdetail> selectByExample(ReportdetailExample example) {
		
		return reportdetailMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ReportdetailExample example) {
		
		return reportdetailMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ReportdetailExample example) {
		
		return reportdetailMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param reportdetail
	 * @return
	 */
	public int checkNameUnique(Reportdetail reportdetail){
		ReportdetailExample example=new ReportdetailExample();
		example.createCriteria().andAreanameEqualTo(reportdetail.getAreaname());
		List<Reportdetail> list=reportdetailMapper.selectByExample(example);
		return list.size();
	}


}
