package com.tax.token.service.impl;


import com.yxcheng.token.common.cache.RedisService;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.common.service.AbstractService;
import com.tax.token.mapper.TkZoneInfoMapper;
import com.tax.token.model.TkZoneInfo;
import com.tax.token.model.TkZoneInfoExample;
import com.tax.token.service.api.TkZoneInfoService;
import com.yxcheng.token.constants.RedisContants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional
@Component
@ComponentScan(basePackages = {"com.tax.token.dao", "com.tax.token.integration"})
public class TkZoneInfoServiceImpl extends AbstractService<TkZoneInfoMapper,TkZoneInfoExample,TkZoneInfo> implements TkZoneInfoService {

    @Autowired
    private RedisService redisService;

    @Override
    public JsonResult<String> refresh() {
        this.baseMapper.selectByExample(new TkZoneInfoExample()).stream().forEach(e->{
            redisService.set(RedisContants.TOKEN_ZONE_IS_NEW + e.getZoneCode(),e,TkZoneInfo.class);
        });
        return new JsonResult<>();
    }
}
