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.ServiceTypeDetail;
import com.izouma.awesomeadmin.service.ServiceTypeDetailService;
import com.izouma.awesomeadmin.dao.ServiceTypeDetailMapper;

/**
*  service接口实现类
*/
@Service
public class ServiceTypeDetailServiceImpl implements ServiceTypeDetailService{

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

    @Autowired
    private ServiceTypeDetailMapper serviceTypeDetailMapper;

    @Override
    public List<ServiceTypeDetail> getServiceTypeDetailList(ServiceTypeDetail record) {

        logger.info("getServiceTypeDetailList");
        try {

        return serviceTypeDetailMapper.queryAllServiceTypeDetail(record);
        } catch (Exception e) {
        logger.error("getServiceTypeDetailList", e);
        }

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

        logger.info("getServiceTypeDetailByPage");
        try {

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

        return serviceTypeDetailMapper.queryServiceTypeDetailByPage(parameter);
        } catch (Exception e) {
        logger.error("getServiceTypeDetailByPage", e);
        }

        return null;
    }

    @Override
    public ServiceTypeDetail getServiceTypeDetailById(String id) {

        logger.info("getServiceTypeDetailyId");
        try {

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

        return null;
    }

    @Override
    public ServiceTypeDetail getServiceTypeDetail(ServiceTypeDetail record) {

        logger.info("getServiceTypeDetail");
        try {

            return serviceTypeDetailMapper.queryServiceTypeDetail(record);
        } catch (Exception e) {
        logger.error("getServiceTypeDetail", e);
        }

        return null;
    }

    @Override
    public boolean createServiceTypeDetail(ServiceTypeDetail record) {

        logger.info("createServiceTypeDetail");
        try {

            int updates = serviceTypeDetailMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteServiceTypeDetail(String id) {

        logger.info("deleteServiceTypeDetail");
        try {

             int updates = serviceTypeDetailMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateServiceTypeDetail(ServiceTypeDetail record) {

        logger.info("updateServiceTypeDetail");
        try {

            int updates = serviceTypeDetailMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

