package com.fizz.business.config;

import cn.hutool.json.JSONObject;

import com.fizz.business.dto.CoilHeadDTO;
import com.fizz.business.dto.CoilPositionDTO;
import com.fizz.business.dto.MatmapDTO;
import com.fizz.business.dto.SegmentDTO;
import com.ruoyi.framework.config.RedisConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;

/**
 * 描述: RedisTemplate配置及序列化
 *
 * @author daiyue
 * @date 2021/3/25
 */
@Configuration
public class RedisTemplateConfig {


    @Bean
    public RedisTemplate<String, List<String>> redisTemplateOfList(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, List<String>> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }



    @Bean
    public RedisTemplate<String, SegmentDTO> redisTemplateOfSegment(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, SegmentDTO> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }

    @Bean
    public RedisTemplate<String, MatmapDTO> redisTemplateOfMatmap(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, MatmapDTO> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }

    @Bean
    public RedisTemplate<String, CoilHeadDTO> redisTemplateOfHead(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, CoilHeadDTO> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }

    @Bean
    public RedisTemplate<String, CoilPositionDTO> redisTemplateOfCoilPos(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, CoilPositionDTO> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }

    @Bean
    public RedisTemplate<String, JSONObject> redisTemplateOfMap(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, JSONObject> redisTemplate = new RedisTemplate<>();
        return RedisConfig.fetchRedisTemplate(redisTemplate, redisConnectionFactory);
    }
}