123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /**
- * Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
- */
- package com.thinkgem.jeesite.common.service;
- import java.util.List;
- import java.util.Map;
- import com.caimei.modules.basesetting.entity.Province;
- import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
- import com.caimei.modules.hehe.entity.HeheOrder;
- import com.caimei.modules.hehe.entity.HeheProduct;
- import com.caimei.modules.hehe.entity.HeheTransaction;
- import com.caimei.modules.order.entity.CmRefundShop;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.transaction.annotation.Transactional;
- import com.thinkgem.jeesite.common.persistence.CrudDao;
- import com.thinkgem.jeesite.common.persistence.DataEntity;
- import com.thinkgem.jeesite.common.persistence.Page;
- /**
- * Service基类
- * @author ThinkGem
- * @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 List<T> findList(T entity) {
- return dao.findList(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 entity
- */
- @Transactional(readOnly = false)
- public void save(T entity) {
- if (entity.getIsNewRecord()){
- entity.preInsert();
- dao.insert(entity);
- }else{
- entity.preUpdate();
- dao.update(entity);
- }
- }
- /**
- * 删除数据
- * @param entity
- */
- @Transactional(readOnly = false)
- public void delete(T entity) {
- dao.delete(entity);
- }
- /**
- * PC端---批量修改启用、禁用状态
- * @param enabledStatus
- * @param ids
- */
- @Transactional(readOnly = false)
- public void updateEnabledStatusByIds(String enabledStatus, String[] ids) {
- dao.updateEnabledStatusByIds(enabledStatus,ids);
- }
- /**
- * crm端---批量修改启用、禁用状态
- * @param enabledStatus
- * @param ids
- */
- @Transactional(readOnly = false)
- public void updateCrmEnabledStatusByIds(String enabledStatus, String[] ids) {
- dao.updateCrmEnabledStatusByIds(enabledStatus,ids);
- }
- }
|