首页 > 代码库 > 封装baseservice
封装baseservice
package com.huawei.base;
import java.io.Serializable;
import java.util.List;
public abstract class BaseService<T,ID extends Serializable> {
//由子类来具体的实现DAO
protected abstract BaseDAO<T, ID> getBaseDAO();
public void save(T o){
//this.save();
this.getBaseDAO().save(o);
}
public List<T> findAll(){
return this.getBaseDAO().findAll();
}
public void delete(ID id){
this.getBaseDAO().delete(id);
}
public void detete(ID[] ids){
this.getBaseDAO().delete(ids);
}
}
package com.huawei.service;
import com.cdsxt.base.BaseDAO;
import com.cdsxt.base.BaseService;
import com.cdsxt.dao.AddressDAO;
import com.cdsxt.po.Address;
public class AddressService extends BaseService<Address, Integer>{
private AddressDAO addressDAO;
@Override
protected BaseDAO<Address, Integer> getBaseDAO() {
return this.addressDAO;
}
}
封装baseservice