yangys
2024-10-30 25db770e621f1259b8d5b7fd514207f7481c2d0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.qianwen.smartman.common.cache;
 
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.tool.utils.SpringUtil;
import com.qianwen.smartman.modules.system.entity.I18nData;
import com.qianwen.smartman.modules.system.service.I18nDataService;
 
public class I18nCache {
    private static final String MESSAGE_CODE_TAG = "i18n:code:tag";
    private static final I18nDataService i18nDataService = (I18nDataService) SpringUtil.getBean(I18nDataService.class);
 
    public static I18nData getByCodeAndLanguageTag(String code, String tag) {
        return (I18nData) CacheUtil.get(ExtCacheConstant.I18N_CACHE, MESSAGE_CODE_TAG, code +  ":"  + tag, () -> {
            return i18nDataService.getByCodeAndLanguageTag(code, tag);
        }, ExtCacheConstant.TENANT_MODE);
    }
}