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.WtReportSubMapper;
import com.gyee.frame.model.auto.WtReportSub;
import com.gyee.frame.model.auto.WtReportSubExample;
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 WtReportSubService implements BaseService<WtReportSub, WtReportSubExample> {
	@Resource
	private WtReportSubMapper wtReportSubMapper;


	@Override
	public int deleteByPrimaryKey(String ids) {

			List<String> lista=Convert.toListStrArray(ids);
			WtReportSubExample example=new WtReportSubExample();
			example.createCriteria().andIdIn(lista);
			return wtReportSubMapper.deleteByExample(example);


	}


	@Override
	public WtReportSub selectByPrimaryKey(String id) {

			return wtReportSubMapper.selectByPrimaryKey(id);

	}


	@Override
	public int updateByPrimaryKeySelective(WtReportSub record) {
		return wtReportSubMapper.updateByPrimaryKeySelective(record);
	}


	/**
	 * 添加
	 */
	@Override
	public int insertSelective(WtReportSub record) {

		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());


		return wtReportSubMapper.insertSelective(record);
	}


	@Override
	public int updateByExampleSelective(WtReportSub record, WtReportSubExample example) {

		return wtReportSubMapper.updateByExampleSelective(record, example);
	}


	@Override
	public int updateByExample(WtReportSub record, WtReportSubExample example) {

		return wtReportSubMapper.updateByExample(record, example);
	}

	@Override
	public List<WtReportSub> selectByExample(WtReportSubExample example) {

		return wtReportSubMapper.selectByExample(example);
	}


	@Override
	public long countByExample(WtReportSubExample example) {

		return wtReportSubMapper.countByExample(example);
	}


	@Override
	public int deleteByExample(WtReportSubExample example) {

		return wtReportSubMapper.deleteByExample(example);
	}

	public List<WtReportSub> findWtReportSubList(String tid) {


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

		if(StringUtils.notEmp(tid))
		{
			WtReportSubExample example=new WtReportSubExample();
			example.setOrderByClause("recodedate asc");

			WtReportSubExample.Criteria criteria =example.createCriteria();

			criteria.andTidEqualTo(tid);

			list= wtReportSubMapper.selectByExample(example);
		}

		return list;

	}
}
