fix(core): 添加 未添加至国际化的资源

添加 未添加至国际化的资源
yun-zuoyi
wynne1005 4 years ago
parent 3518567099
commit c65a1d735c

@ -41,6 +41,8 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import com.alibaba.fastjson.JSONObject;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -75,6 +77,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
@ -149,6 +152,11 @@ public class WhiteController extends CoreBaseController {
@Autowired
private RabbitTemplate rabbitTemplate;
private Cache<String, Integer> unsavedLocaleResSwitch = CacheBuilder.newBuilder()
.maximumSize(1)
.expireAfterWrite(1, TimeUnit.MINUTES)
.build();
@GetMapping(value = "/sys-locale-language/list")
@ApiOperation(value = "查询可用语言", notes = "查询可用语言")
public ResultBean listSysLocaleLanguage() {
@ -690,6 +698,17 @@ public class WhiteController extends CoreBaseController {
@ApiOperation(value = "缺失资源", notes = "缺失资源")
public ResultBean getMissResourceByKey(String key, String menuCode) {
try {
Integer switcher = unsavedLocaleResSwitch.asMap().get(PlatformConstWords.WEB_MISS_RESOURCE_LISTENER_SWITCH);
if (switcher == null) {
switcher = RedisCacheTool.getSysConfigIntVal(PlatformConstWords.WEB_MISS_RESOURCE_LISTENER_SWITCH,
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
unsavedLocaleResSwitch.put(PlatformConstWords.WEB_MISS_RESOURCE_LISTENER_SWITCH, switcher);
}
if (switcher == -1 || switcher == CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) {
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
Map<String, String> missResource = new HashMap<>();
missResource.put(key, menuCode);
rabbitTemplate.convertAndSend(PlatformConstWords.QUEUE_IMPP_RESOURCE, JsonUtilTool.encode(missResource));

Loading…
Cancel
Save