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.Monthlygradeassessmentmain2Mapper;
import com.gyee.frame.model.auto.Monthlygradeassessmentmain2;
import com.gyee.frame.model.auto.Monthlygradeassessmentmain2Example;
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.List;


@Service
public class Monthlygradeassessmentmain2Service implements BaseService<Monthlygradeassessmentmain2, Monthlygradeassessmentmain2Example> {
	@Resource
	private Monthlygradeassessmentmain2Mapper monthlygradeassessmentmain2Mapper;
	

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

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

	
	@Override
	public int updateByExample(Monthlygradeassessmentmain2 record, Monthlygradeassessmentmain2Example example) {
		
		return monthlygradeassessmentmain2Mapper.updateByExample(record, example);
	}

	@Override
	public List<Monthlygradeassessmentmain2> selectByExample(Monthlygradeassessmentmain2Example example) {
		
		return monthlygradeassessmentmain2Mapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(Monthlygradeassessmentmain2Example example) {
		
		return monthlygradeassessmentmain2Mapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(Monthlygradeassessmentmain2Example example) {
		
		return monthlygradeassessmentmain2Mapper.deleteByExample(example);
	}

	public List<Monthlygradeassessmentmain2> getMonthlygradeassessmentmain2ListBywtId(String wtId, String year, String month) {


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

		if (StringUtils.notEmp(wtId) && StringUtils.notEmp(year) && StringUtils.notEmp(month)) {

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

			Monthlygradeassessmentmain2Example.Criteria criteria =example.createCriteria();

			criteria.andWtidEqualTo(wtId);
			criteria.andYearEqualTo(year);
			criteria.andMonthEqualTo(month);
			list= monthlygradeassessmentmain2Mapper.selectByExample(example);

		}
		return list;

	}
}
