Java tutorial
/* * Copyright 2005-2015 shopxx.net. All rights reserved. * Support: http://3936242.01p.com/ * License: http://3936242.01p.com/license */ package net.shopxx.service.impl; import java.util.List; import javax.annotation.Resource; import net.shopxx.Page; import net.shopxx.Pageable; import net.shopxx.dao.ProductNotifyDao; import net.shopxx.entity.Member; import net.shopxx.entity.Product; import net.shopxx.entity.ProductNotify; import net.shopxx.service.MailService; import net.shopxx.service.ProductNotifyService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service("productNotifyServiceImpl") public class ProductNotifyServiceImpl extends BaseServiceImpl<ProductNotify, Long> implements ProductNotifyService { @Resource(name = "productNotifyDaoImpl") private ProductNotifyDao productNotifyDao; @Resource(name = "mailServiceImpl") private MailService mailService; @Transactional(readOnly = true) public boolean exists(Product product, String email) { return productNotifyDao.exists(product, email); } @Transactional(readOnly = true) public Page<ProductNotify> findPage(Member member, Boolean isMarketable, Boolean isOutOfStock, Boolean hasSent, Pageable pageable) { return productNotifyDao.findPage(member, isMarketable, isOutOfStock, hasSent, pageable); } @Transactional(readOnly = true) public Long count(Member member, Boolean isMarketable, Boolean isOutOfStock, Boolean hasSent) { return productNotifyDao.count(member, isMarketable, isOutOfStock, hasSent); } public int send(List<ProductNotify> productNotifies) { if (CollectionUtils.isEmpty(productNotifies)) { return 0; } int count = 0; for (ProductNotify productNotify : productNotifies) { if (productNotify != null && StringUtils.isNotEmpty(productNotify.getEmail())) { mailService.sendProductNotifyMail(productNotify); productNotify.setHasSent(true); count++; } } return count; } }