/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.filing.approvalStage.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.entity.ProjectOverview;
import com.jeeplus.modules.filing.approvalStage.entity.StudyStage;
import com.jeeplus.modules.filing.approvalStage.mapper.ApprovalStageMapper;
import com.jeeplus.modules.filing.approvalStage.mapper.StudyStageMapper;
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 StudyStageService extends CrudService<StudyStageMapper, StudyStage> {


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

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

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

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

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

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

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

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