Java-java-com-util-common-service:CrudService.java

來源:互聯網
上載者:User

標籤:war   com   nsa   pac   blog   資料   find   abs   extends   

ylbtech-Java-java-com-util-common-service:CrudService.java

 

1.返回頂部
1、
package com.shineyoo.manager.util.common.service;import java.util.Collection;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.transaction.annotation.Transactional;import com.shineyoo.manager.util.common.persistence.CrudDao;import com.shineyoo.manager.util.common.persistence.DataEntity;import com.shineyoo.manager.util.common.persistence.Page;/** * Service基類 * @author * @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);    }        /**     * 擷取單條資料     * @param entity     * @return     */    public T get(T entity) {        return dao.get(entity);    }    /**     * 擷取單條資料     * @param entity     * @return     */    public T getNew(T entity) {        return dao.getNew(entity);    }    /**     * 查詢列表資料     * @param entity     * @return     */    public List<T> findList(T entity) {        return dao.findList(entity);    }    /**     * 查詢列表資料     * @param entity     * @return     */    public List<T> findAllList(T entity) {        return dao.findAllList(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;    }        /**     * 查詢分頁資料     * @param page 分頁對象     * @param entity     * @return     */    public Page<T> findPageOver(Page<T> page, T entity) {        entity.setPage(page);        page.setList(dao.findListOver(entity));        return page;    }    /**     * 查詢沒有通過審核的分頁資料     * @param page 分頁對象     * @param entity     * @return     */    public Page<T> findPageByStatus(Page<T> page, T entity) {        entity.setPage(page);        page.setList(dao.findListByStatus(entity));        return page;    }    /**     * 儲存資料(插入或更新)     * @param entity     */    @Transactional(readOnly = false)    public void save(T entity) {        if (entity.getIsNewRecord()){            entity.preInsert();            entity.setDelFlag("0");            dao.insert(entity);        }else{            entity.preUpdate();            dao.update(entity);        }    }        /**     * 刪除資料     * @param entity     */    @Transactional(readOnly = false)    public void delete(T entity) {        dao.delete(entity);    }        /**     * 邏輯刪除資料     * @param entity     */    @Transactional(readOnly = false)    public void deleteByLogic(T entity) {        dao.deleteByLogic(entity);    }            /**     * 刪除全部資料     * @param entitys     */    @Transactional(readOnly = false)    public void deleteAll(Collection<T> entitys) {        for (T entity : entitys) {            dao.delete(entity);        }    }        /**     * 擷取單條資料     * @param propertyName     * @return     */    public T findUniqueByProperty(String propertyName, Object value){        return dao.findUniqueByProperty(propertyName, value);    }}
2、
2.返回頂部
 
3.返回頂部
 
4.返回頂部
 
5.返回頂部
  
6.返回頂部
 
ylbtech
出處:http://ylbtech.cnblogs.com/
本文著作權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文串連,否則保留追究法律責任的權利。

Java-java-com-util-common-service:CrudService.java

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.