package com.web.base;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.poi.ss.usermodel.Cell;
import org.hibernate.Session;
/**
* Generic Manager that talks to GenericDao to CRUD POJOs.
*
* <p>Extend this interface if you want typesafe (no casting necessary) managers
* for your domain objects.
*
* @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
* @param <T> a type variable
* @param <PK> the primary key for that type
*/
public interface BaseService<T, PK extends Serializable> {
/**
* Generic method used to get all objects of a particular type. This
* is the same as lookup up all rows in a table.
* @return List of populated objects
*/
List<T> getAll();
/**
* Generic method to get an object based on class and identifier. An
* ObjectRetrievalFailureException Runtime Exception is thrown if
* nothing is found.
*
* @param id the identifier (primary key) of the object to get
* @return a populated object
* @see org.springframework.orm.ObjectRetrievalFailureException
*/
T get(PK id);
/**
* Checks for existence of an object of type T using the id arg.
* @param id the identifier (primary key) of the object to get
* @return - true if it exists, false if it doesn't
*/
boolean exists(PK id);
/**
* Generic method to save an object - handles both update and insert.
* @param object the object to save
* @return the updated object
*/
T save(T object);
/**
* Generic method to delete an object based on class and id
* @param id the identifier (primary key) of the object to remove
*/
void remove(PK id);
public void removes(PK[] ids);
void remove1(PK id);
public void removes1(PK[] ids);
public List<T> getByHql(String hql,Object[] objs);
public List getAllByHql(String hql,Object[] objs);
public void updateQuery(final String hql,final Map map);
public List<T> getPageData(String hql, Map map, int pageIndex, int pageSize);
public List<T> getPageData(String hql, Map map);
public int getPageSize(String hql, Map map);
public BigDecimal getTotalCount(String hql, Map map);
public String getCellValue(Cell cell);
public void removes2(PK[] ids, Map session);
}
package com.web.base;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
public class BaseServiceImpl<T, PK extends Serializable> implements BaseService<T, PK> {
/**
* Log variable for all child classes. Uses LogFactory.getLog(getClass()) from Commons Logging
*/
protected final Log log = LogFactory.getLog(getClass());
/**
* GenericDao instance, set by constructor of this class
*/
protected BaseDao<T, PK> baseDao;
/**
* Public constructor for creating a new GenericManagerImpl.
* @param genericDao the GenericDao to use for persistence
*/
public BaseServiceImpl(final BaseDao<T, PK> baseDao) {
this.baseDao = baseDao;
}
/**
* {@inheritDoc}
*/
public List<T> getAll() {
return baseDao.getAll();
}
/**
* {@inheritDoc}
*/
public T get(PK id) {
return baseDao.get(id);
}
/**
* {@inheritDoc}
*/
public boolean exists(PK id) {
return baseDao.exists(id);
}
/**
* {@inheritDoc}
*/
public T save(T object) {
return baseDao.save(object);
}
/**
* {@inheritDoc}
*/
public void remove(PK id) {
baseDao.remove1(id);
}
public void removes(PK[] ids){
baseDao.removes1(ids);
}
public void remove1(PK id) {
baseDao.remove(id);
}
public void removes1(PK[] ids){
baseDao.removes(ids);
}
public List<T> getPageData(String hql, Map map, int pageIndex, int pageSize) {
return baseDao.getPageData(hql, map, pageIndex, pageSize);
}
public List<T> getPageData(String hql, Map map) {
return baseDao.getPageData(hql, map);
}
public int getPageSize(String hql, Map map) {
return baseDao.getPageSize(hql,map);
}
public BigDecimal getTotalCount(String hql, Map map){
return baseDao.getTotalCount(hql,map);
}
public List<T> getByHql(String hql, Object[] objs) {
return baseDao.getByHql(hql, objs);
}
public void updateQuery(String hql, Map map) {
baseDao.updateQuery(hql, map);
}
public List getAllByHql(String hql, Object[] objs) {
return baseDao.getAllByHql(hql, objs);
}
public String getCellValue(Cell cell){
if(cell!=null){
if(cell.getCellType()==HSSFCell.CELL_TYPE_NUMERIC)
return String.valueOf(cell.getNumericCellValue());
else return cell.getRichStringCellValue().toString().trim();
}else return null;
}
public void removes2(PK[] ids,Map session) {
baseDao.removes2(ids,session);
}
}
分享到:
相关推荐
java泛型BaseDao与BaseService
springMVC+Mybatis封装整合:整合搭建已经完成不再述,本框架特色主要针对Mybatis框架BaseDao,BaseService,BaseServiceImpl封装,有点贵,本人也是循序见进到这一步,花了将近一个月时间,之前发布版本可以不下载...
在标签中,请指定 name 为baseMapper,baseService,baseServiceImpl,baseController 的value属性(超类位置). 2.本项目中的basic包下可见超类的具体在实现代码.复制粘贴即可. 本应用鼓励使用超类,由JVM实现类型判断,...
.net 分布式缓存中间件 方便实现缓存的分布式,集群,负载均衡,故障自动转移,并兼容多种缓存存储的分布式缓存中间件。 用于解决分布式架构中的分布式缓存环节。
springBoot简单实例,入门级实例,基本框架结构搭建
myBatis代码生成工具
private BaseService employeeService; @Override public String execute() throws Exception { System.out.println(emp.getEmployeeName() + "|" + emp.getEmployeePassword()); // empyloeeService....
基本服务 Goland服务的基本代码
iuap-pap-baseservice框架属于iuap快速开发体系中的后台支持部分,通过与iuap前端开发框架结合,可快速的实现一套业务表单系统开发. 特性 集成图形化快速建模工具—— 快速启动业务表单开发 简化单表/主子表CRUD服务...
SuperMap iClient for 示例演示了扩展ServiceBase类解决Ajax跨域问题
实现了 BaseService 类对 Service 层进行抽象。通过拦截器实现了方法级粒度的鉴权,通过AOP实现了参数校验。 演示: 可自行注册账号,或使用后台查看权限账号 demo 密码 demo (后台入口登陆后显示) 兄弟项目: 本...
这是一个Spring MVC + Mybatis 的项目,不仅仅只是简单的demo或是增删改查,她将含括很多的方面:尽量抽取basedao,baseService公共部分,做出一个简单的framework,为以后分布式开发提供基础。 ##内容 Spring的国际...
Dyd.BaseService.TaskManager源码部署须知: 1,删除各个项目中Newtonsoft.Json.dll的引用 2,检查各项目中XXF.dll的引用,确保引用了“引用”文件夹中的XXF.dll 3,执行,建模脚本.txt中的sql
k3cloud dll文件
DWR+JPA DWR直接访问SERVICE层,并直接处理DAO返回的BEAN
自定义日志模块(接口及代理实现),而不直接使用第三方日志框架接口,避免在日志框架升级或者切换时,代码过多耦合。 这个举例说明一下: 比如,在某一项目开始时使用的是“log4j”框架,后面经过研究发现“sf4j...
加入了Mybatis PageHelper分页组件,并抽象出了BaseService层。另外加入了Shrio完成登录验证和权限部分的验证操作。表包含有用户、角色、权限、角色权限表等,权限部分呢比较简单,用户拥有角色,角色与资源多对多的...
Service继承了baseSevice,baseSevice已经声明了一些基本方法,需要自己定制的方法在service中声明,然后在...BaseService需要一个Dao对实体进行操作,如果要使用BaseAction中的方法,需要把Dao注入到BaseService中。
加入了Mybatis PageHelper分页组件,并抽象出了BaseService层。另外加入了Shrio完成登录验证和权限部分的验证操作。表包含有用户、角色、权限、角色权限表等,权限部分呢比较简单,用户拥有角色,角色与资源多对多的...
import { GET , POST , PUT , PATCH , DELETE , BasePath , Header , Path , Body , BaseService , ServiceBuilder , Response } from "ts-retrofit" ; interface User { id ?: number ; name : string ; email ...