package com.izouma.awesomeadmin.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.izouma.awesomeadmin.dao.RongYunTokenMapper;
import com.izouma.awesomeadmin.model.RongYunToken;
import com.izouma.awesomeadmin.service.RongYunTokenService;

@Service
public class RongYunTokenServiceImpl implements RongYunTokenService {

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

    @Autowired
    private RongYunTokenMapper rongYunTokenMapper;


    @Override
    public RongYunToken getRongToken(String rongKey) {

        logger.info("getRongToken");
        try {

            return rongYunTokenMapper.getRongToken(rongKey);
        } catch (Exception e) {
            logger.error("getRongToken", e);
        }
        return null;
    }


    @Override
    public Boolean saveRongToken(RongYunToken rongYunToken) {

        logger.info("saveRongToken");
        try {

            int updates = rongYunTokenMapper.insertSelective(rongYunToken);

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

}
