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.OrderRepairDetail;
import com.izouma.awesomeadmin.service.OrderRepairDetailService;
import com.izouma.awesomeadmin.dao.OrderRepairDetailMapper;

/**
*  service接口实现类
*/
@Service
public class OrderRepairDetailServiceImpl implements OrderRepairDetailService{

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

    @Autowired
    private OrderRepairDetailMapper orderRepairDetailMapper;

    @Override
    public List<OrderRepairDetail> getOrderRepairDetailList(OrderRepairDetail record) {

        logger.info("getOrderRepairDetailList");
        try {

        return orderRepairDetailMapper.queryAllOrderRepairDetail(record);
        } catch (Exception e) {
        logger.error("getOrderRepairDetailList", e);
        }

        return null;
    }

    @Override
    public List<OrderRepairDetail> getOrderRepairDetailExportRemark(OrderRepairDetail record) {

        logger.info("getOrderRepairDetailExportRemark");
        try {

        return orderRepairDetailMapper.queryAllOrderRepairDetailExportRemark(record);
        } catch (Exception e) {
        logger.error("getOrderRepairDetailExportRemark", e);
        }

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

        logger.info("getOrderRepairDetailByPage");
        try {

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

        return orderRepairDetailMapper.queryOrderRepairDetailByPage(parameter);
        } catch (Exception e) {
        logger.error("getOrderRepairDetailByPage", e);
        }

        return null;
    }

    @Override
    public OrderRepairDetail getOrderRepairDetailById(String id) {

        logger.info("getOrderRepairDetailyId");
        try {

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

        return null;
    }

    @Override
    public OrderRepairDetail getOrderRepairDetail(OrderRepairDetail record) {

        logger.info("getOrderRepairDetail");
        try {

            return orderRepairDetailMapper.queryOrderRepairDetail(record);
        } catch (Exception e) {
        logger.error("getOrderRepairDetail", e);
        }

        return null;
    }

    @Override
    public boolean createOrderRepairDetail(OrderRepairDetail record) {

        logger.info("createOrderRepairDetail");
        try {

            int updates = orderRepairDetailMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteOrderRepairDetail(String id) {

        logger.info("deleteOrderRepairDetail");
        try {

             int updates = orderRepairDetailMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateOrderRepairDetail(OrderRepairDetail record) {

        logger.info("updateOrderRepairDetail");
        try {

            int updates = orderRepairDetailMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

