shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package com.ishop.merchant.config;
 
import com.iplatform.base.FileOperateSpi;
import com.iplatform.base.config.CacheConfiguration;
import com.ishop.merchant.ArticleCategoryCache;
import com.ishop.merchant.CityCacheProvider;
import com.ishop.merchant.ExpressCache;
import com.ishop.merchant.LevelCache;
import com.ishop.merchant.MerCategoryCacheProvider;
import com.ishop.merchant.MerProductCategoryCache;
import com.ishop.merchant.MerTypeCacheProvider;
import com.ishop.merchant.MerchantCache;
import com.ishop.merchant.ProductAttrCache;
import com.ishop.merchant.ProductBrandCache;
import com.ishop.merchant.ProductCache;
import com.ishop.merchant.ProductCategoryCache;
import com.ishop.merchant.UserRegCache;
import com.ishop.merchant.UserRegConfigCache;
import com.ishop.merchant.cache.RedisArticleCateCache;
import com.ishop.merchant.cache.RedisCityCache;
import com.ishop.merchant.cache.RedisExpressCache;
import com.ishop.merchant.cache.RedisLevelCache;
import com.ishop.merchant.cache.RedisMerCategoryCache;
import com.ishop.merchant.cache.RedisMerProductCategoryCache;
import com.ishop.merchant.cache.RedisMerTypeCache;
import com.ishop.merchant.cache.RedisMerchantCache;
import com.ishop.merchant.cache.RedisProductAttrCache;
import com.ishop.merchant.cache.RedisProductBrandCache;
import com.ishop.merchant.cache.RedisProductCache;
import com.ishop.merchant.cache.RedisProductCategoryCache;
import com.ishop.merchant.cache.RedisUserRegCache;
import com.ishop.merchant.cache.RedisUserRegConfigCache;
import com.ishop.merchant.service.ArticleServiceImpl;
import com.ishop.merchant.service.CityServiceImpl;
import com.ishop.merchant.service.ExpressServiceImpl;
import com.ishop.merchant.service.LevelServiceImpl;
import com.ishop.merchant.service.MerchantCategoryServiceImpl;
import com.ishop.merchant.service.MerchantProductCategoryServiceImpl;
import com.ishop.merchant.service.MerchantServiceImpl;
import com.ishop.merchant.service.MerchantTypeServiceImpl;
import com.ishop.merchant.service.ProductAttrServiceImpl;
import com.ishop.merchant.service.ProductBrandServiceImpl;
import com.ishop.merchant.service.ProductCategoryServiceImpl;
import com.ishop.merchant.service.ProductServiceImpl;
import com.ishop.merchant.service.UserRegConfigServiceImpl;
import com.ishop.merchant.service.UserRegisterServiceImpl;
import com.walker.support.redis.RedisHelper;
import com.walker.support.redis.cache.RedisCacheProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
@ConditionalOnProperty(prefix = "iplatform.cache", name = "redis-enabled", havingValue = "true", matchIfMissing = false)
@ConditionalOnClass({RedisCacheProvider.class})
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisMerchantCacheConfig extends CacheConfiguration {
 
    /**
     * 快递公司缓存配置
     * @param redisHelper
     * @param expressService
     * @return
     * @date 2023-08-20
     */
    @Bean
    public ExpressCache expressCache(RedisHelper redisHelper, ExpressServiceImpl expressService){
        RedisExpressCache cache = new RedisExpressCache();
        cache.setRedisHelper(redisHelper);
        cache.setExpressService(expressService);
        return cache;
    }
 
    /**
     * 用户自定义配置缓存
     * @param redisHelper
     * @param userRegConfigService
     * @return
     * @date 2023-08-06
     */
    @Bean
    public UserRegConfigCache userRegConfigCache(RedisHelper redisHelper, UserRegConfigServiceImpl userRegConfigService){
        RedisUserRegConfigCache cache = new RedisUserRegConfigCache();
        cache.setRedisHelper(redisHelper);
        cache.setUserRegConfigService(userRegConfigService);
        return cache;
    }
 
    /**
     * 商品基本信息缓存配置
     * @param redisHelper
     * @param productService
     * @return
     * @date 2023-07-30
     */
    @Bean
    public ProductCache productCache(RedisHelper redisHelper, ProductServiceImpl productService){
        RedisProductCache cache = new RedisProductCache();
        cache.setRedisHelper(redisHelper);
        cache.setProductService(productService);
        return cache;
    }
 
    @Bean
    public ArticleCategoryCache articleCategoryCache(RedisHelper redisHelper, ArticleServiceImpl articleService){
        RedisArticleCateCache cache = new RedisArticleCateCache();
        cache.setRedisHelper(redisHelper);
        cache.setArticleService(articleService);
        return cache;
    }
 
    /**
     * 系统用户等级定义缓存。
     * @param levelService
     * @return
     * @date 2023-06-30
     */
    @Bean
    public LevelCache levelCache(RedisHelper redisHelper, LevelServiceImpl levelService){
        RedisLevelCache cache = new RedisLevelCache();
        cache.setRedisHelper(redisHelper);
        cache.setLevelService(levelService);
        return cache;
    }
 
    /**
     * 城市区域缓存配置。
     * @param redisHelper
     * @param cityService
     * @return
     * @date 2023-06-26
     */
    @Bean
    public CityCacheProvider cityCacheProvider(RedisHelper redisHelper, CityServiceImpl cityService){
        RedisCityCache cache = new RedisCityCache();
        cache.setRedisHelper(redisHelper);
        cache.setCityService(cityService);
        return cache;
    }
 
    /**
     * 前端注册用户缓存定义。
     * @param redisHelper
     * @param userRegisterService
     * @return
     * @date 2023-06-17
     */
    @Bean
    public UserRegCache userRegCache(RedisHelper redisHelper, UserRegisterServiceImpl userRegisterService){
        RedisUserRegCache cache = new RedisUserRegCache();
        cache.setRedisHelper(redisHelper);
        cache.setUserRegisterService(userRegisterService);
        return cache;
    }
 
    /**
     * 商户商品分类缓存。
     * @param redisHelper
     * @param merchantProductCategoryService
     * @return
     * @date 2023-06-16
     */
    @Bean
    public MerProductCategoryCache merProductCategoryCache(RedisHelper redisHelper
            , MerchantProductCategoryServiceImpl merchantProductCategoryService){
        RedisMerProductCategoryCache cache = new RedisMerProductCategoryCache();
        cache.setRedisHelper(redisHelper);
        cache.setMerchantProductCategoryService(merchantProductCategoryService);
        return cache;
    }
 
    /**
     * 商品属性定义缓存,注意:这是个集合缓存,与之前Hash缓存不同。
     * @param productAttrService
     * @return
     * @date 2023-06-14
     */
    @Bean
    public ProductAttrCache productAttrCache(RedisHelper redisHelper, ProductAttrServiceImpl productAttrService){
        RedisProductAttrCache cache = new RedisProductAttrCache();
        cache.setRedisHelper(redisHelper);
        cache.setProductAttrService(productAttrService);
        return cache;
    }
 
    @Bean
    public MerchantCache merchantCache(RedisHelper redisHelper, MerchantServiceImpl merchantService){
        RedisMerchantCache cache = new RedisMerchantCache();
        cache.setRedisHelper(redisHelper);
        cache.setMerchantService(merchantService);
        return cache;
    }
 
    @Bean
    public ProductBrandCache productBrandCache(RedisHelper redisHelper, ProductBrandServiceImpl productBrandService){
        RedisProductBrandCache cache = new RedisProductBrandCache();
        cache.setRedisHelper(redisHelper);
        cache.setProductBrandService(productBrandService);
        return cache;
    }
 
    @Bean
    public ProductCategoryCache productCategoryCache(RedisHelper redisHelper
            , ProductCategoryServiceImpl productCategoryService, FileOperateSpi fileOperateSpi){
        RedisProductCategoryCache cache = new RedisProductCategoryCache();
        cache.setProductCategoryService(productCategoryService);
        cache.setRedisHelper(redisHelper);
        cache.setCdnUrl(fileOperateSpi.getCdnUrl());
        return cache;
    }
 
    @Bean
    public MerCategoryCacheProvider merCategoryCacheProvider(RedisHelper redisHelper, MerchantCategoryServiceImpl merchantCategoryService){
        RedisMerCategoryCache cache = new RedisMerCategoryCache();
        cache.setRedisHelper(redisHelper);
        cache.setMerchantCategoryService(merchantCategoryService);
        return cache;
    }
 
    @Bean
    public MerTypeCacheProvider merTypeCacheProvider(RedisHelper redisHelper, MerchantTypeServiceImpl merchantTypeService){
        RedisMerTypeCache cache = new RedisMerTypeCache();
        cache.setRedisHelper(redisHelper);
        cache.setMerchantTypeService(merchantTypeService);
        return cache;
    }
}