yangys
2024-04-02 6bed83e92f67954cd2135071133329f2205efe4f
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
package com.qianwen.core.tenant.dynamic;
 
import com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor;
import com.baomidou.dynamic.datasource.processor.DsProcessor;
import org.aopalliance.intercept.MethodInvocation;
import com.qianwen.core.secure.utils.AuthUtil;
import com.qianwen.core.tenant.exception.TenantDataSourceException;
 
/* loaded from: blade-starter-tenant-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tenant/dynamic/TenantDataSourceAnnotationInterceptor.class */
public class TenantDataSourceAnnotationInterceptor extends DynamicDataSourceAnnotationInterceptor {
    private TenantDataSourceHolder holder;
 
    public void setHolder(final TenantDataSourceHolder holder) {
        this.holder = holder;
    }
 
    public TenantDataSourceAnnotationInterceptor(Boolean allowedPublicOnly, DsProcessor dsProcessor) {
        super(allowedPublicOnly, dsProcessor);
    }
 
    public Object invoke(MethodInvocation invocation) throws Throwable {
        try {
            this.holder.handleDataSource(AuthUtil.getTenantId());
            return super.invoke(invocation);
        } catch (Exception exception) {
            throw new TenantDataSourceException(exception.getMessage());
        }
    }
}