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.LogisticsInfo;
import com.izouma.awesomeadmin.service.LogisticsInfoService;
import com.izouma.awesomeadmin.dao.LogisticsInfoMapper;

/**
*  service接口实现类
*/
@Service
public class LogisticsInfoServiceImpl implements LogisticsInfoService{

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

    @Autowired
    private LogisticsInfoMapper logisticsInfoMapper;

    @Override
    public List<LogisticsInfo> getLogisticsInfoList(LogisticsInfo record) {

        logger.info("getLogisticsInfoList");
        try {

        return logisticsInfoMapper.queryAllLogisticsInfo(record);
        } catch (Exception e) {
        logger.error("getLogisticsInfoList", e);
        }

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

        logger.info("getLogisticsInfoByPage");
        try {

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

        return logisticsInfoMapper.queryLogisticsInfoByPage(parameter);
        } catch (Exception e) {
        logger.error("getLogisticsInfoByPage", e);
        }

        return null;
    }

    @Override
    public LogisticsInfo getLogisticsInfoById(String id) {

        logger.info("getLogisticsInfoyId");
        try {

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

        return null;
    }

    @Override
    public LogisticsInfo getLogisticsInfo(LogisticsInfo record) {

        logger.info("getLogisticsInfo");
        try {

            return logisticsInfoMapper.queryLogisticsInfo(record);
        } catch (Exception e) {
        logger.error("getLogisticsInfo", e);
        }

        return null;
    }

    @Override
    public boolean createLogisticsInfo(LogisticsInfo record) {

        logger.info("createLogisticsInfo");
        try {

            int updates = logisticsInfoMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteLogisticsInfo(String id) {

        logger.info("deleteLogisticsInfo");
        try {

             int updates = logisticsInfoMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateLogisticsInfo(LogisticsInfo record) {

        logger.info("updateLogisticsInfo");
        try {

            int updates = logisticsInfoMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

