Kaynağa Gözat

国产化改造

hanzhengyi 1 yıl önce
ebeveyn
işleme
51c07c2915

+ 2 - 0
base-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java

@@ -1,5 +1,6 @@
 package com.ruoyi.common.datascope.aspect;
 
+import com.ruoyi.common.datascope.context.DeptContextHolder;
 import com.usky.system.domain.SysUserVO;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.Aspect;
@@ -133,6 +134,7 @@ public class DataScopeAspect
             {
                 BaseEntity baseEntity = (BaseEntity) params;
                 baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
+                DeptContextHolder.setDeptSql(" AND (" + sqlString.substring(4) + ")");
             }
         }
     }

+ 45 - 0
base-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/context/DeptContextHolder.java

@@ -0,0 +1,45 @@
+package com.ruoyi.common.datascope.context;
+
+/**
+ * 多租户上下文 Holder
+ *
+ * @author han
+ */
+public class DeptContextHolder {
+
+    /**
+     * 部门隔离sql
+     */
+    private static final ThreadLocal<String> DEPT_SQL = new ThreadLocal<>();
+
+    /**
+     * 获得部门隔离sql。
+     *
+     * @return 部门隔离sql
+     */
+    public static String getDeptSql() {
+        return DEPT_SQL.get();
+    }
+
+    /**
+     * 获得部门隔离sql。如果不存在,则抛出 NullPointerException 异常
+     * @return 部门隔离sql
+     */
+    public static String getRequiredDeptSql() {
+        String deptSql = getDeptSql();
+        if (deptSql == null) {
+            throw new NullPointerException("DeptContextHolder 不存在部门隔离sql");
+        }
+        return deptSql;
+    }
+
+    public static void setDeptSql(String deptSql) {
+        DEPT_SQL.set(deptSql);
+    }
+
+
+    public static void clear() {
+        DEPT_SQL.remove();
+    }
+
+}

+ 53 - 29
base-modules/service-system/service-system-biz/pom.xml

@@ -11,10 +11,10 @@
     <dependencies>
 
 
-        <dependency>
-            <groupId>com.usky</groupId>
-            <artifactId>common-cloud-starter</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.usky</groupId>-->
+<!--            <artifactId>common-cloud-starter</artifactId>-->
+<!--        </dependency>-->
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -47,7 +47,55 @@
             <groupId>com.usky</groupId>
             <artifactId>ruoyi-common-swagger</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.dm</groupId>
+            <artifactId>DmJdbcDriver</artifactId>
+            <version>1.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-core</artifactId>
+            <version>3.4.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>service-system-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-extension</artifactId>
+            <version>3.4.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>usky-common-mybatis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>usky-common-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>usky-common-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>ruoyi-common-datascope</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>usky-common-log</artifactId>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>druid-spring-boot-starter</artifactId>-->
+<!--        </dependency>-->
     </dependencies>
 
     <build>
@@ -56,31 +104,7 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration> <fork>false</fork> </configuration>
                 <version>2.2.6.RELEASE</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-
-            </plugin>
-            <plugin>
-                <groupId>com.github.shalousun</groupId>
-                <artifactId>smart-doc-maven-plugin</artifactId>
-                <version>2.1.1</version>
-                <configuration>
-                    <!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
-                    <configFile>./src/main/resources/smart-doc.json</configFile>
-                    <!--指定项目名称-->
-                    <projectName>test</projectName>
-                    <!--                    <excludes>-->
-                    <!--                        <exclude>com.bizmatics:product-service-provider</exclude>-->
-                    <!--                        <exclude>cn.afterturn:easypoi-web</exclude>-->
-                    <!--                    </excludes>-->
-                </configuration>
             </plugin>
         </plugins>
     </build>

+ 94 - 0
base-modules/service-system/service-system-biz/src/main/resources/application.yml

@@ -0,0 +1,94 @@
+# Tomcat
+# Spring
+mybatis:
+  refresh:
+    delay-seconds: 10
+    enabled: true
+    sleep-seconds: 20
+mybatis-plus:
+  configuration:
+    defaultStatementTimeout: 3
+    lazy-loading-enabled: true
+    map-underscore-to-camel-case: true
+  global-config:
+    db-config:
+      id-type: auto
+    mapperRegistryCache: true
+  mapper-locations: classpath*:mapper/**/*.xml
+server:
+  port: 9886
+  compression:
+    enabled: true
+    mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
+spring:
+  application:
+    # 应用名称
+    name: usky-system
+  profiles:
+    # 环境配置
+    active: dev
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  cache:
+    ehcache:
+      config: classpath:ehcache.xml
+      enabled: false
+    redis:
+      enabled: true
+  datasource:
+    druid:
+      stat-view-servlet:
+        enabled: true
+        login-password: '@dmin1234'
+        login-username: admin
+        reset-enable: true
+        url-pattern: /druid/*
+    dynamic:
+      datasource:
+        master:
+          driver-class-name: dm.jdbc.driver.DmDriver
+          password: usky888666
+          url: jdbc:dm://172.16.120.151:5236/USKY-CLOUD?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
+          username: usky-fire
+      druid:
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        maxWait: 60000
+        timeBetweenEvictionRunsMillis: 60000
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        filters: stat,slf4j
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      primary: master
+  jackson:
+    date-format: yyyy-MM-dd HH:mm:ss
+    default-property-inclusion: always
+    deserialization:
+      fail-on-unknown-properties: false
+    parser:
+      allow-single-quotes: true
+      allow-unquoted-control-chars: true
+    serialization:
+      fail-on-empty-beans: false
+    time-zone: GMT+8
+  redis:
+    host: 172.16.120.165
+    password: 123456
+    port: 6379
+    timeout: 10000
+  influx:
+    url: http://172.16.120.69:8086
+    password: root
+    user: root
+    database: USKTSDB
+  tenant:
+    enable: true
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher

+ 0 - 24
base-modules/service-system/service-system-biz/src/main/resources/bootstrap.yml

@@ -1,24 +0,0 @@
-# Tomcat
-server:
-  port: 9886
-# Spring
-spring:
-  application:
-    # 应用名称
-    name: usky-system
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: usky-cloud-nacos:8848
-      config:
-        # 配置中心地址
-        server-addr: usky-cloud-nacos:8848
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 4 - 3
base-modules/service-system/service-system-biz/src/main/resources/config/application-dev.yml

@@ -37,9 +37,10 @@ spring:
     dynamic:
       datasource:
         master:
-          password: password
-          url: jdbc:mysql://172.16.120.165:3306/usky-cloud?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowMultiQueries=true
-          username: root
+          driver-class-name: dm.jdbc.driver.DmDriver
+          password: usky888666
+          url: jdbc:dm://172.16.120.151:5236/USKY-CLOUD?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
+          username: usky-fire
       druid:
         initial-size: 5
         min-idle: 5