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


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

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

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

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

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



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

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

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