net.shopxx.service.impl.DeliveryCenterServiceImpl.java Source code

Java tutorial

Introduction

Here is the source code for net.shopxx.service.impl.DeliveryCenterServiceImpl.java

Source

/*
 * 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 javax.annotation.Resource;

import net.shopxx.dao.DeliveryCenterDao;
import net.shopxx.entity.DeliveryCenter;
import net.shopxx.service.DeliveryCenterService;

import org.apache.commons.lang.BooleanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

@Service("deliveryCenterServiceImpl")
public class DeliveryCenterServiceImpl extends BaseServiceImpl<DeliveryCenter, Long>
        implements DeliveryCenterService {

    @Resource(name = "deliveryCenterDaoImpl")
    private DeliveryCenterDao deliveryCenterDao;

    @Transactional(readOnly = true)
    public DeliveryCenter findDefault() {
        return deliveryCenterDao.findDefault();
    }

    @Override
    @Transactional
    public DeliveryCenter save(DeliveryCenter deliveryCenter) {
        Assert.notNull(deliveryCenter);

        if (BooleanUtils.isTrue(deliveryCenter.getIsDefault())) {
            deliveryCenterDao.setDefault(deliveryCenter);
        }
        return super.save(deliveryCenter);
    }

    @Override
    @Transactional
    public DeliveryCenter update(DeliveryCenter deliveryCenter) {
        Assert.notNull(deliveryCenter);

        if (BooleanUtils.isTrue(deliveryCenter.getIsDefault())) {
            deliveryCenterDao.setDefault(deliveryCenter);
        }
        return super.update(deliveryCenter);
    }

}