package com.hzs.sale.product.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.sale.classify.BdClassify;
import com.hzs.common.domain.sale.postage.BdPostage;
import com.hzs.sale.product.mapper.BdClassifyMapper;
import com.hzs.sale.product.service.IBdClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 规格分类 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2022-08-26
 */
@Service
public class BdClassifyServiceImpl extends ServiceImpl<BdClassifyMapper, BdClassify> implements IBdClassifyService {

    @Autowired
    private RedisService redisService;
    /**
     * 根据id 查询详情
     * @param classifyId
     * @return
     */
    @Override
    public BdClassify getClassify(Integer classifyId) {
        String redisKey = CacheConstants.BD_CLASSIFY + classifyId;
        BdClassify classify = redisService.getCacheObject(redisKey);
        if (null == classify) {
            classify = baseMapper.selectById(classifyId);
            if (null != classify) {
                redisService.setCacheObject(redisKey, classify);
            }
        }
        return classify;
    }
}
