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.Daylygradeassessmentmain2Mapper;
import com.gyee.frame.model.auto.Daylygradeassessmentmain2;
import com.gyee.frame.model.auto.Daylygradeassessmentmain2Example;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.util.SnowflakeIdWorker;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class Daylygradeassessmentmain2Service implements BaseService<Daylygradeassessmentmain2, Daylygradeassessmentmain2Example> {
	@Resource
	private Daylygradeassessmentmain2Mapper daylygradeassessmentmain2Mapper;
	

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

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

	
	@Override
	public int updateByExample(Daylygradeassessmentmain2 record, Daylygradeassessmentmain2Example example) {
		
		return daylygradeassessmentmain2Mapper.updateByExample(record, example);
	}

	@Override
	public List<Daylygradeassessmentmain2> selectByExample(Daylygradeassessmentmain2Example example) {
		
		return daylygradeassessmentmain2Mapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(Daylygradeassessmentmain2Example example) {
		
		return daylygradeassessmentmain2Mapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(Daylygradeassessmentmain2Example example) {
		
		return daylygradeassessmentmain2Mapper.deleteByExample(example);
	}


	public List<Daylygradeassessmentmain2> getDaylygradeassessmentmain2ListBywtId(String wtId, Date recorddate) {

		List<Daylygradeassessmentmain2> list=new ArrayList<>();

		if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate) ) {

			Daylygradeassessmentmain2Example example=new Daylygradeassessmentmain2Example();
			example.setOrderByClause("recorddate DESC");

			Daylygradeassessmentmain2Example.Criteria criteria =example.createCriteria();

			Date endDate= DateUtils.addDays(recorddate,1);
			criteria.andRecorddateGreaterThanOrEqualTo(recorddate).andRecorddateLessThan(endDate);

			criteria.andWtidEqualTo(wtId);
			list= daylygradeassessmentmain2Mapper.selectByExample(example);

		}
		return list;

	}

	public List<Daylygradeassessmentmain2> getDaylygradeassessmentmain2ListBywtId(String wtId, Date beginDate, Date endDate) {

		List<Daylygradeassessmentmain2> list=new ArrayList<>();

		if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate) ) {

			Daylygradeassessmentmain2Example example=new Daylygradeassessmentmain2Example();
			example.setOrderByClause("recorddate DESC");

			Daylygradeassessmentmain2Example.Criteria criteria =example.createCriteria();

			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);

			criteria.andWtidEqualTo(wtId);
			list= daylygradeassessmentmain2Mapper.selectByExample(example);

		}
		return list;

	}
}
