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


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.common.domain.sale.product.BdAreaClassify;
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;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hzs
 * @since 2022-11-01
 */
@Service
public class BdBonusServiceServiceImpl extends ServiceImpl<BdBonusServiceMapper, BdBonusService> implements IBdBonusServiceService {

    @Autowired
    private RedisService redisService;

    /**
     * 根据id 查询服务补贴
     */
    @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;
    }

    @Override
    public List<BdBonusService> queryBonusService() {
        QueryWrapper<BdBonusService> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("PK_ID,SERVICE_TYPE,SERVICE_RADIO,ASSESSMENT_TYPE,PK_COUNTRY");
        return baseMapper.selectList(queryWrapper);
    }
}
