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.OrderRepair;
import com.izouma.awesomeadmin.service.OrderRepairService;
import com.izouma.awesomeadmin.dao.OrderRepairMapper;

/**
*  service接口实现类
*/
@Service
public class OrderRepairServiceImpl implements OrderRepairService{

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

    @Autowired
    private OrderRepairMapper orderRepairMapper;

    @Override
    public List<OrderRepair> getOrderRepairList(OrderRepair record) {

        logger.info("getOrderRepairList");
        try {

        return orderRepairMapper.queryAllOrderRepair(record);
        } catch (Exception e) {
        logger.error("getOrderRepairList", e);
        }

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

        logger.info("getOrderRepairByPage");
        try {

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

        return orderRepairMapper.queryOrderRepairByPage(parameter);
        } catch (Exception e) {
        logger.error("getOrderRepairByPage", e);
        }

        return null;
    }

    @Override
    public OrderRepair getOrderRepairById(String id) {

        logger.info("getOrderRepairyId");
        try {

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

        return null;
    }

    @Override
    public OrderRepair getOrderRepair(OrderRepair record) {

        logger.info("getOrderRepair");
        try {

            return orderRepairMapper.queryOrderRepair(record);
        } catch (Exception e) {
        logger.error("getOrderRepair", e);
        }

        return null;
    }

    @Override
    public boolean createOrderRepair(OrderRepair record) {

        logger.info("createOrderRepair");
        try {

            int updates = orderRepairMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteOrderRepair(String id) {

        logger.info("deleteOrderRepair");
        try {

             int updates = orderRepairMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateOrderRepair(OrderRepair record) {

        logger.info("updateOrderRepair");
        try {

            int updates = orderRepairMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

