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

Java tutorial

Introduction

Here is the source code for net.shopxx.service.impl.DeliveryTemplateServiceImpl.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.DeliveryTemplateDao;
import net.shopxx.entity.DeliveryTemplate;
import net.shopxx.service.DeliveryTemplateService;

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

@Service("deliveryTemplateServiceImpl")
public class DeliveryTemplateServiceImpl extends BaseServiceImpl<DeliveryTemplate, Long>
        implements DeliveryTemplateService {

    @Resource(name = "deliveryTemplateDaoImpl")
    private DeliveryTemplateDao deliveryTemplateDao;

    @Transactional(readOnly = true)
    public DeliveryTemplate findDefault() {
        return deliveryTemplateDao.findDefault();
    }

    @Override
    @Transactional
    public DeliveryTemplate save(DeliveryTemplate deliveryTemplate) {
        Assert.notNull(deliveryTemplate);

        if (BooleanUtils.isTrue(deliveryTemplate.getIsDefault())) {
            deliveryTemplateDao.setDefault(deliveryTemplate);
        }
        return super.save(deliveryTemplate);
    }

    @Override
    @Transactional
    public DeliveryTemplate update(DeliveryTemplate deliveryTemplate) {
        Assert.notNull(deliveryTemplate);

        if (BooleanUtils.isTrue(deliveryTemplate.getIsDefault())) {
            deliveryTemplateDao.setDefault(deliveryTemplate);
        }
        return super.update(deliveryTemplate);
    }

}