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.QuickLinks;
import com.izouma.awesomeadmin.service.QuickLinksService;
import com.izouma.awesomeadmin.dao.QuickLinksMapper;

/**
*  service接口实现类
*/
@Service
public class QuickLinksServiceImpl implements QuickLinksService{

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

    @Autowired
    private QuickLinksMapper quickLinksMapper;

    @Override
    public List<QuickLinks> getQuickLinksList(QuickLinks record) {

        logger.info("getQuickLinksList");
        try {

        return quickLinksMapper.queryAllQuickLinks(record);
        } catch (Exception e) {
        logger.error("getQuickLinksList", e);
        }

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

        logger.info("getQuickLinksByPage");
        try {

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

        return quickLinksMapper.queryQuickLinksByPage(parameter);
        } catch (Exception e) {
        logger.error("getQuickLinksByPage", e);
        }

        return null;
    }

    @Override
    public QuickLinks getQuickLinksById(String id) {

        logger.info("getQuickLinksyId");
        try {

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

        return null;
    }

    @Override
    public QuickLinks getQuickLinks(QuickLinks record) {

        logger.info("getQuickLinks");
        try {

            return quickLinksMapper.queryQuickLinks(record);
        } catch (Exception e) {
        logger.error("getQuickLinks", e);
        }

        return null;
    }

    @Override
    public boolean createQuickLinks(QuickLinks record) {

        logger.info("createQuickLinks");
        try {

            int updates = quickLinksMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteQuickLinks(String id) {

        logger.info("deleteQuickLinks");
        try {

             int updates = quickLinksMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateQuickLinks(QuickLinks record) {

        logger.info("updateQuickLinks");
        try {

            int updates = quickLinksMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

