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.VuforiaImageGroup;
import com.izouma.awesomeadmin.service.VuforiaImageGroupService;
import com.izouma.awesomeadmin.dao.VuforiaImageGroupMapper;

/**
*  service接口实现类
*/
@Service
public class VuforiaImageGroupServiceImpl implements VuforiaImageGroupService{

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

    @Autowired
    private VuforiaImageGroupMapper vuforiaImageGroupMapper;

    @Override
    public List<VuforiaImageGroup> getVuforiaImageGroupList(VuforiaImageGroup record) {

        logger.info("getVuforiaImageGroupList");
        try {

        return vuforiaImageGroupMapper.queryAllVuforiaImageGroup(record);
        } catch (Exception e) {
        logger.error("getVuforiaImageGroupList", e);
        }

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

        logger.info("getVuforiaImageGroupByPage");
        try {

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

        return vuforiaImageGroupMapper.queryVuforiaImageGroupByPage(parameter);
        } catch (Exception e) {
        logger.error("getVuforiaImageGroupByPage", e);
        }

        return null;
    }

    @Override
    public VuforiaImageGroup getVuforiaImageGroupById(String id) {

        logger.info("getVuforiaImageGroupyId");
        try {

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

        return null;
    }

    @Override
    public VuforiaImageGroup getVuforiaImageGroup(VuforiaImageGroup record) {

        logger.info("getVuforiaImageGroup");
        try {

            return vuforiaImageGroupMapper.queryVuforiaImageGroup(record);
        } catch (Exception e) {
        logger.error("getVuforiaImageGroup", e);
        }

        return null;
    }

    @Override
    public boolean createVuforiaImageGroup(VuforiaImageGroup record) {

        logger.info("createVuforiaImageGroup");
        try {

            int updates = vuforiaImageGroupMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteVuforiaImageGroup(VuforiaImageGroup record) {

        logger.info("deleteVuforiaImageGroup");
        try {

             int updates = vuforiaImageGroupMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateVuforiaImageGroup(VuforiaImageGroup record) {

        logger.info("updateVuforiaImageGroup");
        try {

            int updates = vuforiaImageGroupMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

