CrudService.java 4.85 KB
/**
 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.common.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.CrudDao;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;

/**
 * Service基类
 * @author ThinkGem
 * @version 2014-05-16
 */
@Transactional(readOnly = true)
public abstract class CrudService<D extends CrudDao<T>, T extends DataEntity<T>> extends BaseService {
	
	/**
	 * 持久层对象
	 */
	@Autowired
	protected D dao;
	
	/**
	 * 获取单条数据
	 * @param id
	 * @return
	 */
	public T get(String id) {
		return dao.get(id);
	}
	public T getbdcdyh(String getbdcdyh) {
		return dao.getbdcdyh(getbdcdyh);
	}
	
	public T getdy(String bdcdyh) {
		return dao.getdy(bdcdyh);
	}
	public T zrzgetdy(String bdcdyh){
		return dao.zrzgetdy(bdcdyh);
	}
	public List<T> findByYwh(String ywh){
		return dao.findByYwh(ywh);
	}
	
	/**
	 * 获取单条数据
	 * @param entity
	 * @return
	 */
	public T get(T entity) {
		return dao.get(entity);
	}
	
	/**
	 * 查询列表数据
	 * @param entity
	 * @return
	 */
	public List<T> findList(T entity) {
		return dao.findList(entity);
	}
	
	public List<T> getListByZddm(T entity) {
		return dao.getListByZddm(entity);
	}
	public List<T> bdcqzshfindlistbdcdyh(T entity) {
		return dao.bdcqzshfindlistbdcdyh(entity);
	}
	public List<T> findList_1(T entity) {
		return dao.findList_1(entity);
	}
	public List<T> findListSxh(T entity) {
		return dao.findListSxh(entity);
	}
	public List<T> findListxf(T entity) {
		return dao.findListxf(entity);
	}

	
	/**
	 * 查询列表数据
	 * @param entity
	 * @return
	 */
	public List<T> findzyList(T entity) {
		return dao.findzyList(entity);
	}

	public List<T> findxfList(T entity) {
		return dao.findxfPage(entity);
	}
	
	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param entity
	 * @return
	 */
	public Page<T> findPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findList(entity));
		return page;
	}
	public Page<T> findBGPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findBGList(entity));
		return page;
	}
	public Page<T> findgmPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findgmList(entity));
		return page;
	}
	public Page<T> findfwqlrgmPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findfwqlrgmList(entity));
		return page;
	}
	
	public Page<T> findPageSxh(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findListSxh(entity));
		return page;
	}
	public Page<T> findPage_1(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findList_1(entity));
		return page;
	}
	
	public Page<T> findFwlinkPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findFwlinkList(entity));
		return page;
	}
	public Page<T> findxfPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findxfPage(entity));
		return page;
	}
	public Page<T> findfwsyqPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findfwsyqPage(entity));
		return page;
	}
	public Page<T> findygPage(Page<T> page, T entity) {
		entity.setPage(page);
		page.setList(dao.findygPage(entity));
		return page;
	}

	/**
	 * 保存数据(插入或更新)
	 * @param entity
	 */
	@Transactional(readOnly = false)
	public void save(T entity) {
		if (entity.getIsNewRecord()){
			entity.preInsert();
			dao.insert(entity);
		}else{
			entity.preUpdate();
			dao.update(entity);
		}
	}
	
	/**
	 * 林权多条登记保存数据
	 * @param entity
	 */
	@Transactional(readOnly = false)
	public void save2(T entity) {
		if (entity.getIsNewRecord()){
			entity.preInsert();
			dao.insert(entity);
		}
	}
	/**
	 * 保存数据(插入或更新)
	 * @param entity
	 */
	/*@Transactional(readOnly = false)
	public void saveDr(T entity) {
		if (entity.getIsNewRecord()){
			entity.preInsert();
			dao.saveDrInsert(entity);			
		}else{
			entity.preUpdate();
			dao.saveDrUpdate(entity);
		}
	}*/
	
	/*
	 * 导入房屋信息用的
	 */
	@Transactional(readOnly = false)
	public void save1(T entity) {
			entity.preInsert1();
			dao.insert(entity);
	}
	
	/**
	 * 批量保存数据(插入)
	 * @param entity
	 */
	@Transactional(readOnly = false)
	public void savebat(T entity) {
		entity.preBatInsert();
		dao.insert(entity);
	}
	
	/**ss
	 * 删除数据
	 * @param entity
	 */
	@Transactional(readOnly = false)
	public void delete(T entity) {
		dao.delete(entity);
	}
	@Transactional(readOnly = false)
	public void deleteywh(String entity) {
		dao.deleteywh(entity);
	}

	@Transactional(readOnly = false)
	public void deletexfdy(T entity) {
		dao.deletexfdy(entity);
	}
	
}