package com.qianwen.smartman.modules.sync.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import java.lang.invoke.SerializedLambda;
|
import java.time.Duration;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Objects;
|
import java.util.stream.Collectors;
|
import com.qianwen.smartman.common.constant.CommonConstant;
|
import com.qianwen.smartman.common.utils.MessageUtils;
|
import com.qianwen.core.log.exception.ServiceException;
|
import com.qianwen.core.mp.base.BaseServiceImpl;
|
import com.qianwen.core.mp.support.Condition;
|
import com.qianwen.core.redis.cache.BladeRedis;
|
import com.qianwen.core.tool.utils.Func;
|
import com.qianwen.smartman.modules.notify.service.INotifyConfigService;
|
import com.qianwen.smartman.modules.sync.constant.DingConstant;
|
import com.qianwen.smartman.modules.sync.constant.OuterAppConfigConstant;
|
import com.qianwen.smartman.modules.sync.constant.QyWechatConstant;
|
import com.qianwen.smartman.modules.sync.convert.OuterAppConfigConvert;
|
import com.qianwen.smartman.modules.sync.entity.OuterAppConfig;
|
import com.qianwen.smartman.modules.sync.mapper.OuterAppConfigMapper;
|
import com.qianwen.smartman.modules.sync.service.IOuterAppConfigService;
|
import com.qianwen.smartman.modules.sync.vo.OuterAppConfigVO;
|
import com.qianwen.smartman.modules.system.service.IUserOauthService;
|
import org.springframework.context.annotation.Lazy;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
@Service
|
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/sync/service/impl/OuterAppConfigServiceImpl.class */
|
public class OuterAppConfigServiceImpl extends BaseServiceImpl<OuterAppConfigMapper, OuterAppConfig> implements IOuterAppConfigService {
|
private final BladeRedis bladeRedis;
|
private final IUserOauthService userOauthService;
|
private final INotifyConfigService notifyConfigService;
|
|
private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
|
String implMethodName = lambda.getImplMethodName();
|
boolean z = true;
|
switch (implMethodName.hashCode()) {
|
case 242925765:
|
if (implMethodName.equals("getAppType")) {
|
z = true;
|
break;
|
}
|
break;
|
case 799509265:
|
if (implMethodName.equals("getSource")) {
|
z = false;
|
break;
|
}
|
break;
|
case 803533544:
|
if (implMethodName.equals("getStatus")) {
|
z = true;
|
break;
|
}
|
break;
|
case 859984188:
|
if (implMethodName.equals("getUserId")) {
|
z = true;
|
break;
|
}
|
break;
|
}
|
switch (z) {
|
case false:
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
|
return (v0) -> {
|
return v0.getSource();
|
};
|
}
|
break;
|
case true:
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
|
return (v0) -> {
|
return v0.getStatus();
|
};
|
}
|
break;
|
case true:
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
|
return (v0) -> {
|
return v0.getUserId();
|
};
|
}
|
break;
|
case true:
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/sync/entity/OuterAppConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
|
return (v0) -> {
|
return v0.getAppType();
|
};
|
}
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/sync/entity/OuterAppConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
|
return (v0) -> {
|
return v0.getAppType();
|
};
|
}
|
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/sync/entity/OuterAppConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
|
return (v0) -> {
|
return v0.getAppType();
|
};
|
}
|
break;
|
}
|
throw new IllegalArgumentException("Invalid lambda deserialization");
|
}
|
|
public OuterAppConfigServiceImpl(BladeRedis bladeRedis, IUserOauthService userOauthService, @Lazy INotifyConfigService notifyConfigService) {
|
this.bladeRedis = bladeRedis;
|
this.userOauthService = userOauthService;
|
this.notifyConfigService = notifyConfigService;
|
}
|
|
@Override // org.springblade.modules.sync.service.IOuterAppConfigService
|
public OuterAppConfig getAppConfig(Integer appType) {
|
Object configObj = this.bladeRedis.get(OuterAppConfigConstant.OUTER_APP_CONFIG + appType);
|
if (Func.isNotEmpty(configObj)) {
|
return (OuterAppConfig) Func.convert(configObj, OuterAppConfig.class);
|
}
|
OuterAppConfig dingAppConfig = (OuterAppConfig) getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
|
return v0.getAppType();
|
}, appType));
|
this.bladeRedis.setEx(OuterAppConfigConstant.OUTER_APP_CONFIG + appType, dingAppConfig, Duration.ofDays(7L));
|
return dingAppConfig;
|
}
|
|
@Override // org.springblade.modules.sync.service.IOuterAppConfigService
|
@Transactional
|
public Boolean unbind(Integer type) {
|
this.bladeRedis.del(OuterAppConfigConstant.OUTER_APP_CONFIG + type);
|
this.userOauthService.update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().eq((v0) -> {
|
return v0.getSource();
|
}, type.equals(OuterAppConfigConstant.QY_WECHAT) ? QyWechatConstant.QY_SOURCE : DingConstant.DING_AUTH_KEY)).set((v0) -> {
|
return v0.getUserId();
|
}, (Object) null));
|
return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().eq((v0) -> {
|
return v0.getAppType();
|
}, type)).set((v0) -> {
|
return v0.getStatus();
|
}, CommonConstant.DEACTIVATE)));
|
}
|
|
@Override // org.springblade.modules.sync.service.IOuterAppConfigService
|
public OuterAppConfigVO submit(OuterAppConfigVO outerAppConfigVO) {
|
OuterAppConfig dingAppConfig = (OuterAppConfig) getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
|
return v0.getAppType();
|
}, outerAppConfigVO.getAppType().equals(OuterAppConfigConstant.QY_WECHAT) ? OuterAppConfigConstant.DING : OuterAppConfigConstant.QY_WECHAT));
|
if (Func.isNotEmpty(dingAppConfig) && dingAppConfig.getStatus().equals(CommonConstant.ENABLE)) {
|
throw new ServiceException(MessageUtils.message("sys.outer.config.is.bind", new Object[0]));
|
}
|
OuterAppConfig outerAppConfig = OuterAppConfigConvert.INSTANCE.convert(outerAppConfigVO);
|
outerAppConfig.setStatus(CommonConstant.ENABLE);
|
saveOrUpdate(outerAppConfig);
|
this.bladeRedis.del(OuterAppConfigConstant.OUTER_APP_CONFIG + outerAppConfigVO.getAppType());
|
this.bladeRedis.del(new String[]{QyWechatConstant.TOKEN_KEY + QyWechatConstant.QY_APP_TYPE, QyWechatConstant.TOKEN_KEY + QyWechatConstant.BOOK_TYPE, DingConstant.DING_ACCESSTOKEN_REDIS_CACHE});
|
this.notifyConfigService.updateServerConfig(outerAppConfig);
|
return OuterAppConfigConvert.INSTANCE.convert(outerAppConfig);
|
}
|
|
@Override // org.springblade.modules.sync.service.IOuterAppConfigService
|
public List<OuterAppConfigVO> getConfigs(Map<String, Object> params) {
|
List<OuterAppConfig> list = list(Condition.getQueryWrapper(params, OuterAppConfig.class));
|
Map<Long, OuterAppConfig> configMap = (Map) list.parallelStream().collect(Collectors.toMap((v0) -> {
|
return v0.getId();
|
}, config -> {
|
return config;
|
}));
|
List<OuterAppConfigVO> configVOS = OuterAppConfigConvert.INSTANCE.convert(list);
|
configVOS.forEach(config2 -> {
|
OuterAppConfig appConfig = (OuterAppConfig) configMap.get(config2.getId());
|
if (!Objects.isNull(appConfig) && appConfig.getAppType().equals(OuterAppConfigConstant.QY_WECHAT)) {
|
config2.setWxDomain(appConfig.getDomainUrl());
|
} else if (!Objects.isNull(appConfig) && appConfig.getAppType().equals(OuterAppConfigConstant.DING)) {
|
config2.setDingDomain(appConfig.getDomainUrl());
|
}
|
});
|
return configVOS;
|
}
|
}
|