package com.ghy.order.service.impl;

import com.ghy.order.domain.OrderBehavior;
import com.ghy.order.mapper.OrderBehaviorMapper;
import com.ghy.order.service.OrderBehaviorService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @author HH
 */
@Service
public class OrderBehaviorServiceImpl implements OrderBehaviorService {

    @Resource
    private OrderBehaviorMapper orderBehaviorMapper;

    @Override
    public int insert(@Valid OrderBehavior orderBehavior) {
        return orderBehaviorMapper.insert(orderBehavior);
    }

    @Override
    public int delete(Long id) {
        return orderBehaviorMapper.delete(id);
    }

    @Override
    public int batchDelete(Set<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return 0;
        }
        return orderBehaviorMapper.batchDelete(ids);
    }

    @Override
    public OrderBehavior selectById(Long id) {
        if (id == null || id < 1) {
            return null;
        }
        return orderBehaviorMapper.selectById(id);
    }

    @Override
    public List<OrderBehavior> selectByIds(Set<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }
        return orderBehaviorMapper.selectByIds(ids);
    }

    @Override
    public List<OrderBehavior> select(OrderBehavior orderBehavior) {
        return orderBehaviorMapper.select(orderBehavior);
    }
}
