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.CompanyInfoDetail;
import com.izouma.awesomeadmin.service.CompanyInfoDetailService;
import com.izouma.awesomeadmin.dao.CompanyInfoDetailMapper;

/**
*  service接口实现类
*/
@Service
public class CompanyInfoDetailServiceImpl implements CompanyInfoDetailService{

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

    @Autowired
    private CompanyInfoDetailMapper companyInfoDetailMapper;

    @Override
    public List<CompanyInfoDetail> getCompanyInfoDetailList(CompanyInfoDetail record) {

        logger.info("getCompanyInfoDetailList");
        try {

        return companyInfoDetailMapper.queryAllCompanyInfoDetail(record);
        } catch (Exception e) {
        logger.error("getCompanyInfoDetailList", e);
        }

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

        logger.info("getCompanyInfoDetailByPage");
        try {

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

        return companyInfoDetailMapper.queryCompanyInfoDetailByPage(parameter);
        } catch (Exception e) {
        logger.error("getCompanyInfoDetailByPage", e);
        }

        return null;
    }

    @Override
    public CompanyInfoDetail getCompanyInfoDetailById(String id) {

        logger.info("getCompanyInfoDetailyId");
        try {

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

        return null;
    }

    @Override
    public CompanyInfoDetail getCompanyInfoDetail(CompanyInfoDetail record) {

        logger.info("getCompanyInfoDetail");
        try {

            return companyInfoDetailMapper.queryCompanyInfoDetail(record);
        } catch (Exception e) {
        logger.error("getCompanyInfoDetail", e);
        }

        return null;
    }

    @Override
    public boolean createCompanyInfoDetail(CompanyInfoDetail record) {

        logger.info("createCompanyInfoDetail");
        try {

            int updates = companyInfoDetailMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteCompanyInfoDetail(CompanyInfoDetail record) {

        logger.info("deleteCompanyInfoDetail");
        try {

             int updates = companyInfoDetailMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateCompanyInfoDetail(CompanyInfoDetail record) {

        logger.info("updateCompanyInfoDetail");
        try {

            int updates = companyInfoDetailMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

