/**
 * 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.EarlyStage;
import com.jeeplus.modules.filing.approvalStage.entity.ProjectOverview;
import com.jeeplus.modules.filing.approvalStage.mapper.ApprovalStageMapper;
import com.jeeplus.modules.filing.approvalStage.mapper.ProjectOverviewMapper;
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 ProjectOverviewService extends CrudService<ProjectOverviewMapper, ProjectOverview> {


	@Override
	public ProjectOverview get(String id) {
		return super.get(id);
	}

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

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

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

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

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

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

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