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.FacedInfo;
import com.izouma.awesomeadmin.service.FacedInfoService;
import com.izouma.awesomeadmin.dao.FacedInfoMapper;

/**
*  service接口实现类
*/
@Service
public class FacedInfoServiceImpl implements FacedInfoService{

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

    @Autowired
    private FacedInfoMapper facedInfoMapper;

    @Override
    public List<FacedInfo> getFacedInfoList(FacedInfo record) {

        logger.info("getFacedInfoList");
        try {

        return facedInfoMapper.queryAllFacedInfo(record);
        } catch (Exception e) {
        logger.error("getFacedInfoList", e);
        }

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

        logger.info("getFacedInfoByPage");
        try {

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

        return facedInfoMapper.queryFacedInfoByPage(parameter);
        } catch (Exception e) {
        logger.error("getFacedInfoByPage", e);
        }

        return null;
    }

    @Override
    public FacedInfo getFacedInfoById(String id) {

        logger.info("getFacedInfoyId");
        try {

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

        return null;
    }

    @Override
    public FacedInfo getFacedInfo(FacedInfo record) {

        logger.info("getFacedInfo");
        try {

            return facedInfoMapper.queryFacedInfo(record);
        } catch (Exception e) {
        logger.error("getFacedInfo", e);
        }

        return null;
    }

    @Override
    public boolean createFacedInfo(FacedInfo record) {

        logger.info("createFacedInfo");
        try {

            int updates = facedInfoMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteFacedInfo(String id) {

        logger.info("deleteFacedInfo");
        try {

             int updates = facedInfoMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateFacedInfo(FacedInfo record) {

        logger.info("updateFacedInfo");
        try {

            int updates = facedInfoMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

