/**
 * 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.ApprovalStage;
import com.jeeplus.modules.filing.approvalStage.mapper.ApprovalStageMapper;
import com.jeeplus.modules.filing.earlyEngineering.entity.DesignStage;
import com.jeeplus.modules.filing.earlyEngineering.entity.EarlyEngineering;
import com.jeeplus.modules.filing.earlyEngineering.mapper.DesignStageMapper;
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 DesignStageService extends CrudService<DesignStageMapper, DesignStage> {


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

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

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

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

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



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

	@Override
	@Transactional(readOnly = false)
	public void save(DesignStage 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(DesignStage entity) {
		return mapper.findByCode(entity);
	}


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