Ylbtech-java-java-com-util-common-service:crudservice.java |
1.
PackageCom.shineyoo.manager.util.common.service;Importjava.util.Collection;Importjava.util.List;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.transaction.annotation.Transactional;ImportCom.shineyoo.manager.util.common.persistence.CrudDao;Importcom.shineyoo.manager.util.common.persistence.DataEntity;ImportCom.shineyoo.manager.util.common.persistence.Page;/*** Service base class *@author * @version2014-05-16*/@Transactional (readOnly=true) Public Abstract classCrudservice<dextendsCruddao<t>, TextendsDataentity<t>>extendsBaseservice {/*** Persistent Layer object*/@AutowiredprotectedD DAO; /*** Get A single piece of data *@paramID *@return */ PublicT get (String ID) {returndao.get (ID); } /*** Get A single piece of data *@paramEntity *@return */ Publict get (t entity) {returnDao.get (entity); } /*** Get A single piece of data *@paramEntity *@return */ PublicT getnew (t entity) {returndao.getnew (entity); } /*** Query list data *@paramEntity *@return */ PublicList<t>findlist (T entity) {returndao.findlist (entity); } /*** Query list data *@paramEntity *@return */ PublicList<t>findalllist (T entity) {returndao.findalllist (entity); } /*** Query Paging data *@paramPage Pagination Object *@paramEntity *@return */ PublicPage<t> Findpage (page<t>page, T entity) {entity.setpage (page); Page.setlist (Dao.findlist (entity)); returnpage; } /*** Query Paging data *@paramPage Pagination Object *@paramEntity *@return */ PublicPage<t> Findpageover (page<t>page, T entity) {entity.setpage (page); Page.setlist (Dao.findlistover (entity)); returnpage; } /*** Query for paginated data without approval *@paramPage Pagination Object *@paramEntity *@return */ PublicPage<t> Findpagebystatus (page<t>page, T entity) {entity.setpage (page); Page.setlist (Dao.findlistbystatus (entity)); returnpage; } /*** Save data (INSERT or UPDATE) *@paramEntity*/@Transactional (readOnly=false) Public voidSave (T entity) {if(Entity.getisnewrecord ()) {Entity.preinsert (); Entity.setdelflag ("0"); Dao.insert (entity); }Else{entity.preupdate (); Dao.update (entity); } } /*** Delete Data *@paramEntity*/@Transactional (readOnly=false) Public voidDelete (T entity) {Dao.delete (entity); } /*** Tombstone Data *@paramEntity*/@Transactional (readOnly=false) Public voiddeletebylogic (T entity) {Dao.deletebylogic (entity); } /*** Delete all data *@paramEntitys*/@Transactional (readOnly=false) Public voidDeleteAll (collection<t>entitys) { for(T entity:entitys) {dao.delete (entity); } } /*** Get A single piece of data *@paramPropertyName *@return */ PublicT Finduniquebyproperty (String PropertyName, Object value) {returnDao.finduniquebyproperty (propertyname, value); }}
2.
|
Ylbtech Source: http://ylbtech.cnblogs.com/ This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility. |
Java-java-com-util-common-service:crudservice.java