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.VuforiaImageType;
import com.izouma.awesomeadmin.service.VuforiaImageTypeService;
import com.izouma.awesomeadmin.dao.VuforiaImageTypeMapper;

/**
*  service接口实现类
*/
@Service
public class VuforiaImageTypeServiceImpl implements VuforiaImageTypeService{

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

    @Autowired
    private VuforiaImageTypeMapper vuforiaImageTypeMapper;

    @Override
    public List<VuforiaImageType> getVuforiaImageTypeList(VuforiaImageType record) {

        logger.info("getVuforiaImageTypeList");
        try {

        return vuforiaImageTypeMapper.queryAllVuforiaImageType(record);
        } catch (Exception e) {
        logger.error("getVuforiaImageTypeList", e);
        }

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

        logger.info("getVuforiaImageTypeByPage");
        try {

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

        return vuforiaImageTypeMapper.queryVuforiaImageTypeByPage(parameter);
        } catch (Exception e) {
        logger.error("getVuforiaImageTypeByPage", e);
        }

        return null;
    }

    @Override
    public VuforiaImageType getVuforiaImageTypeById(String id) {

        logger.info("getVuforiaImageTypeyId");
        try {

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

        return null;
    }

    @Override
    public VuforiaImageType getVuforiaImageType(VuforiaImageType record) {

        logger.info("getVuforiaImageType");
        try {

            return vuforiaImageTypeMapper.queryVuforiaImageType(record);
        } catch (Exception e) {
        logger.error("getVuforiaImageType", e);
        }

        return null;
    }

    @Override
    public boolean createVuforiaImageType(VuforiaImageType record) {

        logger.info("createVuforiaImageType");
        try {

            int updates = vuforiaImageTypeMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteVuforiaImageType(VuforiaImageType record) {

        logger.info("deleteVuforiaImageType");
        try {

             int updates = vuforiaImageTypeMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateVuforiaImageType(VuforiaImageType record) {

        logger.info("updateVuforiaImageType");
        try {

            int updates = vuforiaImageTypeMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

