/**
 * 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.earlyEngineering.entity.ApplicationFor;
import com.jeeplus.modules.filing.earlyEngineering.entity.BiddingContract;
import com.jeeplus.modules.filing.earlyEngineering.mapper.ApplicationForMapper;
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 ApplicationForService extends CrudService<ApplicationForMapper, ApplicationFor> {


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

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

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

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

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



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

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

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