package com.izouma.awesomeadmin.service.impl;

import java.util.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.izouma.awesomeadmin.constant.AppConstant;
import com.izouma.awesomeadmin.dto.Page;
import com.izouma.awesomeadmin.model.OrderLogistics;
import com.izouma.awesomeadmin.service.OrderLogisticsService;
import com.izouma.awesomeadmin.dao.OrderLogisticsMapper;

/**
*  service接口实现类
*/
@Service
public class OrderLogisticsServiceImpl implements OrderLogisticsService{

    private static Logger logger = Logger.getLogger(OrderLogisticsServiceImpl.class);

    @Autowired
    private OrderLogisticsMapper orderLogisticsMapper;

    @Override
    public List<OrderLogistics> getOrderLogisticsList(OrderLogistics record) {

        logger.info("getOrderLogisticsList");
        try {

        return orderLogisticsMapper.queryAllOrderLogistics(record);
        } catch (Exception e) {
        logger.error("getOrderLogisticsList", e);
        }

        return null;
    }
    @Override
    public List<OrderLogistics> getOrderLogisticsByPage(Page page, OrderLogistics record) {

        logger.info("getOrderLogisticsByPage");
        try {

        Map<String, Object> parameter = new HashMap<String, Object>();
        parameter.put("record", record);
        parameter.put(AppConstant.PAGE, page);

        return orderLogisticsMapper.queryOrderLogisticsByPage(parameter);
        } catch (Exception e) {
        logger.error("getOrderLogisticsByPage", e);
        }

        return null;
    }

    @Override
    public OrderLogistics getOrderLogisticsById(String id) {

        logger.info("getOrderLogisticsyId");
        try {

            return orderLogisticsMapper.selectByPrimaryKey(Integer.valueOf(id));
        } catch (Exception e) {
        logger.error("getOrderLogisticsById", e);
        }

        return null;
    }

    @Override
    public OrderLogistics getOrderLogistics(OrderLogistics record) {

        logger.info("getOrderLogistics");
        try {

            return orderLogisticsMapper.queryOrderLogistics(record);
        } catch (Exception e) {
        logger.error("getOrderLogistics", e);
        }

        return null;
    }

    @Override
    public boolean createOrderLogistics(OrderLogistics record) {

        logger.info("createOrderLogistics");
        try {

            int updates = orderLogisticsMapper.insertSelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
            logger.error("createOrderLogistics", e);
        }

        return false;
    }

    @Override
    public boolean deleteOrderLogistics(String id) {

        logger.info("deleteOrderLogistics");
        try {

             int updates = orderLogisticsMapper.delete(id);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("deleteOrderLogistics", e);
        }

        return false;
    }

    @Override
    public boolean updateOrderLogistics(OrderLogistics record) {

        logger.info("updateOrderLogistics");
        try {

            int updates = orderLogisticsMapper.updateByPrimaryKeySelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("updateOrderLogistics", e);
        }

        return false;
    }
}

