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.StoreLabel;
import com.izouma.awesomeadmin.service.StoreLabelService;
import com.izouma.awesomeadmin.dao.StoreLabelMapper;

/**
*  service接口实现类
*/
@Service
public class StoreLabelServiceImpl implements StoreLabelService{

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

    @Autowired
    private StoreLabelMapper storeLabelMapper;

    @Override
    public List<StoreLabel> getStoreLabelList(StoreLabel record) {

        logger.info("getStoreLabelList");
        try {

        return storeLabelMapper.queryAllStoreLabel(record);
        } catch (Exception e) {
        logger.error("getStoreLabelList", e);
        }

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

        logger.info("getStoreLabelByPage");
        try {

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

        return storeLabelMapper.queryStoreLabelByPage(parameter);
        } catch (Exception e) {
        logger.error("getStoreLabelByPage", e);
        }

        return null;
    }

    @Override
    public StoreLabel getStoreLabelById(String id) {

        logger.info("getStoreLabelyId");
        try {

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

        return null;
    }

    @Override
    public StoreLabel getStoreLabel(StoreLabel record) {

        logger.info("getStoreLabel");
        try {

            return storeLabelMapper.queryStoreLabel(record);
        } catch (Exception e) {
        logger.error("getStoreLabel", e);
        }

        return null;
    }

    @Override
    public boolean createStoreLabel(StoreLabel record) {

        logger.info("createStoreLabel");
        try {

            int updates = storeLabelMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteStoreLabel(String id) {

        logger.info("deleteStoreLabel");
        try {

             int updates = storeLabelMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateStoreLabel(StoreLabel record) {

        logger.info("updateStoreLabel");
        try {

            int updates = storeLabelMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

