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.HouseFeature;
import com.izouma.awesomeadmin.service.HouseFeatureService;
import com.izouma.awesomeadmin.dao.HouseFeatureMapper;

/**
*  service接口实现类
*/
@Service
public class HouseFeatureServiceImpl implements HouseFeatureService{

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

    @Autowired
    private HouseFeatureMapper houseFeatureMapper;

    @Override
    public List<HouseFeature> getHouseFeatureList(HouseFeature record) {

        logger.info("getHouseFeatureList");
        try {

        return houseFeatureMapper.queryAllHouseFeature(record);
        } catch (Exception e) {
        logger.error("getHouseFeatureList", e);
        }

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

        logger.info("getHouseFeatureByPage");
        try {

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

        return houseFeatureMapper.queryHouseFeatureByPage(parameter);
        } catch (Exception e) {
        logger.error("getHouseFeatureByPage", e);
        }

        return null;
    }

    @Override
    public HouseFeature getHouseFeatureById(String id) {

        logger.info("getHouseFeatureyId");
        try {

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

        return null;
    }

    @Override
    public HouseFeature getHouseFeature(HouseFeature record) {

        logger.info("getHouseFeature");
        try {

            return houseFeatureMapper.queryHouseFeature(record);
        } catch (Exception e) {
        logger.error("getHouseFeature", e);
        }

        return null;
    }

    @Override
    public boolean createHouseFeature(HouseFeature record) {

        logger.info("createHouseFeature");
        try {

            int updates = houseFeatureMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteHouseFeature(String id) {

        logger.info("deleteHouseFeature");
        try {

             int updates = houseFeatureMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateHouseFeature(HouseFeature record) {

        logger.info("updateHouseFeature");
        try {

            int updates = houseFeatureMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

