/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.filing.earlyEngineering.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.filing.approvalStage.entity.EarlyStage;
import com.jeeplus.modules.filing.earlyEngineering.entity.ReviewStage;
import com.jeeplus.modules.filing.earlyEngineering.mapper.ReviewStageMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 核准阶段Service
 *
 * @author qy
 * @version 2021-03-25
 */
@Service
@Transactional(readOnly = true)
public class ReviewStageService extends CrudService<ReviewStageMapper, ReviewStage> {


	@Override
	public ReviewStage get(ReviewStage entity) {
		return super.get(entity);
	}

	@Override
	public List<ReviewStage> findList(ReviewStage entity) {
		return super.findList(entity);
	}

	@Override
	public Page<ReviewStage> findPage(Page<ReviewStage> page, ReviewStage entity) {
		return super.findPage(page, entity);
	}

	public Page<ReviewStage> findAllPage(Page<ReviewStage> page, ReviewStage entity){
		dataRuleFilter(entity);
		entity.setPage(page);
		page.setList(mapper.findAllList(entity));
		return page;
	}

	public Page<ReviewStage> findChildPage(Page<ReviewStage> page, ReviewStage entity) {
		dataRuleFilter(entity);
		entity.setPage(page);
		page.setList(mapper.findChildList(entity));
		return page;
	}



	@Override
	public void delete(ReviewStage entity) {
		super.delete(entity);
	}

	@Override
	@Transactional(readOnly = false)
	public void save(ReviewStage entity) {
		Integer byCode = mapper.findByCode(entity);
		if (0 == byCode || null == byCode) {
			entity.preInsert();
			mapper.insert(entity);
		} else {
			entity.preUpdate();
			mapper.update(entity);
		}
	}

	public Integer findByCode(ReviewStage entity) {
		return mapper.findByCode(entity);
	}

	public List<ReviewStage> findChildList(ReviewStage entity) {
		return mapper.findChildList(entity);
	}
}