package com.neusoft.smart.pos.ota;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import javax.annotation.PostConstruct;

@SpringCloudApplication
@MapperScan("com.neusoft.smart.pos.*.persistent.mapper")
@ComponentScan("com.neusoft.smart.pos")
@EnableFeignClients
public class ServiceOTAApplication {

	@Autowired
	private RedisTemplate redisTemplate;
	
	public static void main(String[] args) {
		SpringApplication.run(ServiceOTAApplication.class, args);
	}
	
	@PostConstruct
	public RedisTemplate init() {
		redisTemplate.setKeySerializer(new StringRedisSerializer());
		redisTemplate.setHashKeySerializer(new StringRedisSerializer());
		redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
		redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
		return redisTemplate;
	}
}
