net.groupbuy.service.impl.MemberRankServiceImpl.java Source code

Java tutorial

Introduction

Here is the source code for net.groupbuy.service.impl.MemberRankServiceImpl.java

Source

/*
 * Copyright 2005-2013 shopxx.net. All rights reserved.
 * Support: http://www.shopxx.net
 * License: http://www.shopxx.net/license
 */
package net.groupbuy.service.impl;

import java.math.BigDecimal;

import javax.annotation.Resource;

import net.groupbuy.dao.MemberRankDao;
import net.groupbuy.entity.MemberRank;
import net.groupbuy.service.MemberRankService;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Service - 
 * 
 * @author SHOP++ Team
 * @version 3.0
 */
@Service("memberRankServiceImpl")
public class MemberRankServiceImpl extends BaseServiceImpl<MemberRank, Long> implements MemberRankService {

    @Resource(name = "memberRankDaoImpl")
    private MemberRankDao memberRankDao;

    @Resource(name = "memberRankDaoImpl")
    public void setBaseDao(MemberRankDao memberRankDao) {
        super.setBaseDao(memberRankDao);
    }

    @Transactional(readOnly = true)
    public boolean nameExists(String name) {
        return memberRankDao.nameExists(name);
    }

    @Transactional(readOnly = true)
    public boolean nameUnique(String previousName, String currentName) {
        if (StringUtils.equalsIgnoreCase(previousName, currentName)) {
            return true;
        } else {
            if (memberRankDao.nameExists(currentName)) {
                return false;
            } else {
                return true;
            }
        }
    }

    @Transactional(readOnly = true)
    public boolean amountExists(BigDecimal amount) {
        return memberRankDao.amountExists(amount);
    }

    @Transactional(readOnly = true)
    public boolean amountUnique(BigDecimal previousAmount, BigDecimal currentAmount) {
        if (previousAmount != null && previousAmount.compareTo(currentAmount) == 0) {
            return true;
        } else {
            if (memberRankDao.amountExists(currentAmount)) {
                return false;
            } else {
                return true;
            }
        }
    }

    @Transactional(readOnly = true)
    public MemberRank findDefault() {
        return memberRankDao.findDefault();
    }

    @Transactional(readOnly = true)
    public MemberRank findByAmount(BigDecimal amount) {
        return memberRankDao.findByAmount(amount);
    }

}