package com.hzs.system.bonus.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.service.RedisService;
import com.hzs.common.domain.bonus.BdBonusService;
import com.hzs.system.bonus.mapper.BdBonusServiceMapper;
import com.hzs.system.bonus.service.IBdBonusServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 服务实现类
 */
@Service
public class BdBonusServiceServiceImpl extends ServiceImpl<BdBonusServiceMapper, BdBonusService> implements IBdBonusServiceService {

    @Autowired
    private RedisService redisService;

    @Override
    public BdBonusService getBonusServiceById(Integer pkId) {
        String redisKey = CacheConstants.BD_BONUS_SERVICE + pkId;
        BdBonusService bonusService = redisService.getCacheObject(redisKey);
        if (null == bonusService) {
            bonusService = baseMapper.selectById(pkId);
            if (null != bonusService) {
                redisService.setCacheObject(redisKey, bonusService);
            }
        }
        return bonusService;
    }

}
