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.CustomerService;
import com.izouma.awesomeadmin.service.CustomerServiceService;
import com.izouma.awesomeadmin.dao.CustomerServiceMapper;

/**
 * service接口实现类
 */
@Service
public class CustomerServiceServiceImpl implements CustomerServiceService {

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

    @Autowired
    private CustomerServiceMapper customerServiceMapper;

    @Override
    public List<CustomerService> getCustomerServiceList(CustomerService record) {

        logger.info("getCustomerServiceList");
        try {

            return customerServiceMapper.queryAllCustomerService(record);
        } catch (Exception e) {
            logger.error("getCustomerServiceList", e);
        }

        return null;
    }

    @Override
    public List<CustomerService> getCustomerServiceByPage(Page page, CustomerService record) {

        logger.info("getCustomerServiceByPage");
        try {

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

            return customerServiceMapper.queryCustomerServiceByPage(parameter);
        } catch (Exception e) {
            logger.error("getCustomerServiceByPage", e);
        }

        return null;
    }

    @Override
    public CustomerService getCustomerServiceById(String id) {

        logger.info("getCustomerServiceyId");
        try {

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

        return null;
    }

    @Override
    public CustomerService getCustomerService(CustomerService record) {

        logger.info("getCustomerService");
        try {

            return customerServiceMapper.queryCustomerService(record);
        } catch (Exception e) {
            logger.error("getCustomerService", e);
        }

        return null;
    }

    @Override
    public boolean createCustomerService(CustomerService record) {

        logger.info("createCustomerService");
        try {

            int updates = customerServiceMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteCustomerService(CustomerService record) {

        logger.info("deleteCustomerService");
        try {

            int updates = customerServiceMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateCustomerService(CustomerService record) {

        logger.info("updateCustomerService");
        try {

            int updates = customerServiceMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }

    @Override
    public List<CustomerService> getRecentlyLoginList(CustomerService record) {

        logger.info("getRecentlyLoginList");
        try {

            return customerServiceMapper.getRecentlyLoginList(record);
        } catch (Exception e) {
            logger.error("getRecentlyLoginList", e);
        }

        return null;
    }
}

