/**
 * 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.LegalCompliance;
import com.jeeplus.modules.filing.earlyEngineering.entity.ReviewStage;
import com.jeeplus.modules.filing.earlyEngineering.mapper.LegalComplianceMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 依法合规MAPPER接口
 * @author qy
 * @version 2021-04-06
 */
@Service
@Transactional(readOnly = true)
public class LegalComplianceService extends CrudService<LegalComplianceMapper, LegalCompliance> {


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

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

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

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

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



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

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

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