zl程序教程

您现在的位置是:首页 >  后端

当前栏目

javaEE架构必须懂的知识Base类

架构 知识 必须 base JavaEE
2023-09-11 14:16:34 时间
import java.util.List;

import org.springframework.dao.DataAccessException;

import com.yuanchuangyun.framework.entity.BaseEntity;


public interface BaseDaoMapper<T extends BaseEntity> {
	
    public <PK> T getById(PK id)throws DataAccessException;

    public void save(T entity)throws DataAccessException;

    public void update(T entity)throws DataAccessException;

    public <PK> void deleteById(PK id)throws DataAccessException;
    
    public List<T> getAllData() throws DataAccessException;
    
    public List<T> getByEntity(T entity) throws DataAccessException;
    
    public void deleteByIds(List<String> ids)throws DataAccessException;
    
    
}

public class BaseEntity implements java.io.Serializable{

	/**
	 * serialVersionUID:
	 *
	 * @since Ver 1.1
	 */
	
	private static final long serialVersionUID = 4831177830237254301L;
	
	

}


import java.util.List;

import com.yuanchuangyun.framework.entity.BaseEntity;
import com.yuanchuangyun.framework.exception.ServiceException;


public interface BaseService <T extends BaseEntity> {
	
    public <PK> T getById(PK id)throws ServiceException;

    public void save(T entity)throws ServiceException;

    public void update(T entity)throws ServiceException;

    public List<T> getAllData() throws ServiceException;
    
    public List<T> getByEntity(T entity) throws ServiceException;
    
    public <PK> void deleteByIds(List<String> ids)throws ServiceException;
}


public class ServiceException extends RuntimeException
{

	private static final long serialVersionUID = -2440105546095427374L;

	public ServiceException()
	{
		super();
	}

	public ServiceException(String message)
	{
		super(message);
	}

	public ServiceException(String message, Throwable cause)
	{
		super(message, cause);
	}

	public ServiceException(Throwable cause)
	{
		super(cause);
	}
}