Переглянути джерело

update ipad以及qw-api-msg启动

ct 4 днів тому
батько
коміт
9732044adb

+ 2 - 2
fs-company/src/main/resources/application-dev.yml

@@ -4,8 +4,8 @@ spring:
 #        restart:
 #            enabled: false
     redis:
-#        host: localhost
-        host: 172.27.0.7
+        host: localhost
+#        host: 172.27.0.7
         port: 6379
         # 数据库索引
         database: 0

+ 0 - 180
fs-ipad-task/src/main/java/com/fs/framework/aspectj/TenantDataSourceAspect.java

@@ -1,180 +0,0 @@
-package com.fs.framework.aspectj;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import com.fs.common.annotation.TenantDataScope;
-import com.fs.common.core.redis.RedisCacheT;
-import com.fs.common.enums.TenantIdType;
-import com.fs.common.exception.CustomException;
-import com.fs.common.utils.StringUtils;
-import com.fs.framework.datasource.DynamicDataSource;
-import com.fs.framework.datasource.DynamicDataSourceContextHolder;
-import com.fs.huifuPay.sdk.opps.core.exception.BasePayException;
-import com.fs.tenant.domain.TenantInfo;
-import com.fs.tenant.mapper.TenantInfoMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 多数据源处理
- *
- */
-@Slf4j
-@Aspect
-@Order(1)
-@Component
-public class TenantDataSourceAspect {
-    private static final String TENANT_KEY = "tenant:info:";
-    @Resource
-    private DynamicDataSource dynamicDataSource;
-    @Value("${tenant-id}")
-    private Long ymlTenantId;
-    @Autowired
-    private TenantInfoMapper tenantInfoMapper;
-    @Autowired
-    private RedisCacheT<TenantInfo> redis;
-    /**
-     * 租户数据源缓存
-     */
-    private static final Map<String, DataSource> TENANT_DS_CACHE = new ConcurrentHashMap<>();
-
-    @Pointcut("@annotation(com.fs.common.annotation.TenantDataScope)"
-            + "|| @within(com.fs.common.annotation.TenantDataScope)")
-    public void dsPointCut() {
-
-    }
-
-    @Around("dsPointCut()")
-    public Object around(ProceedingJoinPoint point) throws Throwable {
-        MethodSignature signature = (MethodSignature) point.getSignature();
-        Method targetMethod = signature.getMethod(); // 拿到目标方法对象
-        log.info("执行方法:{}", targetMethod.getName());
-        TenantDataScope dataSource = getDataSource(point);
-        TenantIdType type = dataSource.type();
-        Long tenantId = 0L;
-        if(type.equals(TenantIdType.YML)){
-            tenantId = ymlTenantId;
-        }
-        if(type.equals(TenantIdType.REQUEST)){
-
-        }
-        switchTenant(tenantId);
-        try {
-            return point.proceed();
-        } finally {
-            // 销毁数据源 在执行方法之后
-            DynamicDataSourceContextHolder.clearDataSourceType();
-        }
-    }
-
-    public void switchTenant(Long id) {
-        TenantInfo tenantInfo = redis.getCacheObject(TENANT_KEY + id);
-        if(tenantInfo == null){
-            tenantInfo = tenantInfoMapper.selectById(id);
-            if(tenantInfo == null){
-                throw new CustomException("租户不存在请检查");
-            }
-            redis.setCacheObject(TENANT_KEY + id, tenantInfo);
-        }
-        // 用租户主键作为唯一标识
-        String tenantKey = buildTenantKey(tenantInfo.getId());
-
-        if (!TENANT_DS_CACHE.containsKey(tenantKey)) {
-            synchronized (this) {
-                if (!TENANT_DS_CACHE.containsKey(tenantKey)) {
-
-                    javax.sql.DataSource tenantDs = createTenantDataSource(tenantInfo);
-                    TENANT_DS_CACHE.put(tenantKey, tenantDs);
-
-                    // 动态追加到已解析的数据源
-                    Map<Object, DataSource> resolvedMap = getResolvedDataSources();
-                    resolvedMap.put(tenantKey, tenantDs);
-                }
-            }
-        }
-
-        // ThreadLocal 切库
-        DynamicDataSourceContextHolder.setDataSourceType(tenantKey);
-    }
-
-    private String buildTenantKey(Long tenantId) {
-        return "tenant:" + tenantId;
-    }
-
-
-
-    /**
-     * 清理 ThreadLocal
-     */
-    public void clear() {
-        DynamicDataSourceContextHolder.clearDataSourceType();
-    }
-
-    /**
-     * 创建租户数据源(MySQL + Druid)
-     */
-    private DataSource createTenantDataSource(TenantInfo tenant) {
-
-        DruidDataSource ds = new DruidDataSource();
-        ds.setUrl(tenant.getDbUrl());
-        ds.setUsername(tenant.getDbAccount());
-        ds.setPassword(tenant.getDbPwd());
-
-        // 统一 MySQL
-        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
-
-        ds.setInitialSize(5);
-        ds.setMinIdle(10);
-        ds.setMaxActive(20);
-        ds.setMaxWait(60000);
-
-        return ds;
-    }
-
-    /**
-     * 反射获取 AbstractRoutingDataSource.resolvedDataSources
-     */
-    @SuppressWarnings("unchecked")
-    private Map<Object, DataSource> getResolvedDataSources() {
-        try {
-            Field field = org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
-                    .class.getDeclaredField("resolvedDataSources");
-            field.setAccessible(true);
-            return (Map<Object, DataSource>) field.get(dynamicDataSource);
-        } catch (Exception e) {
-            throw new IllegalStateException("获取 resolvedDataSources 失败", e);
-        }
-    }
-
-    /**
-     * 获取需要切换的数据源
-     */
-    public TenantDataScope getDataSource(ProceedingJoinPoint point) {
-        MethodSignature signature = (MethodSignature) point.getSignature();
-        TenantDataScope dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), TenantDataScope.class);
-        if (Objects.nonNull(dataSource)) {
-            return dataSource;
-        }
-
-        return AnnotationUtils.findAnnotation(signature.getDeclaringType(), TenantDataScope.class);
-    }
-}

+ 2 - 2
fs-ipad-task/src/main/resources/application.yml

@@ -4,6 +4,6 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: dev-test
+    active: dev,common
 group-no: 1
-tenant-id: 29
+tenant-id: 33

+ 1 - 1
fs-qw-api-msg/src/main/resources/application.yml

@@ -3,7 +3,7 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: dev
+    active: dev,common
 #    active: druid-jzzx
 #    active: druid-hdt
 #    active: druid-sxjz

+ 3 - 3
fs-service/src/main/java/com/fs/qw/service/impl/QwUserServiceImpl.java

@@ -1358,9 +1358,9 @@ public class QwUserServiceImpl implements IQwUserService
         }
         WxWorkSetCallbackUrlDTO wxWorkSetCallbackUrlDTO = new WxWorkSetCallbackUrlDTO();
 
-        System.out.println("回调地址"+"http://saasqwapimsg.ylrzcloud.com/msg/callback/"+serverId + "/"+loginParam.getTenantId());
-        wxWorkSetCallbackUrlDTO.setUrl("http://saasqwapimsg.ylrzcloud.com/msg/callback/"+serverId+ "/"+loginParam.getTenantId());
-        //wxWorkSetCallbackUrlDTO.setUrl("http://cn-hk-bgp-4.ofalias.net:55081/msg/callback/"+serverId+ "/"+loginParam.getTenantId());
+        System.out.println("回调地址"+"http://newsaasqwapimsg.ylrzcloud.com/msg/callback/"+serverId + "/"+loginParam.getTenantId());
+        wxWorkSetCallbackUrlDTO.setUrl("http://newsaasqwapimsg.ylrzcloud.com/msg/callback/"+serverId+ "/"+loginParam.getTenantId());
+//        wxWorkSetCallbackUrlDTO.setUrl("http://t66e9dea.natappfree.cc/msg/callback/"+serverId+ "/"+loginParam.getTenantId());
         wxWorkSetCallbackUrlDTO.setUuid(data.getUuid());
         wxWorkService.SetCallbackUrl(wxWorkSetCallbackUrlDTO,serverId);
 

+ 3 - 0
fs-service/src/main/resources/application-common.yml

@@ -159,4 +159,7 @@ comm:
     internal-secret: CommGatewayInternal2026!@#
     enabled: true
     fallback-local: true
+baidu:
+  token: 12313231232
+  back-domain: https://www.xxxx.com
 

+ 2 - 2
fs-service/src/main/resources/application-dev.yml

@@ -3,8 +3,8 @@ spring:
     # redis 配置
     redis:
         # 地址
-        #host: localhost
-        host: 172.27.0.7
+        host: localhost
+#        host: 172.27.0.7
         # 端口,默认为6379
         port: 6379
         # 数据库索引