فهرست منبع

mysql迁移pgsql

1037015548@qq.com 2 سال پیش
والد
کامیت
e8bac4c5af

+ 10 - 0
ruoyi-admin/pom.xml

@@ -73,6 +73,16 @@
             <artifactId>afirma-lib-jmimemagic</artifactId>
             <version>0.0.6</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+            <version>42.2.18</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 4 - 4
ruoyi-admin/src/main/resources/application-dev.yml

@@ -61,9 +61,9 @@ spring:
             slave:
                 # 从数据源开关/默认关闭
                 enabled: false
-                url: 
-                username: 
-                password: 
+                url:
+                username:
+                password:
             # 初始连接数
             initialSize: 5
             # 最小连接池数量
@@ -83,7 +83,7 @@ spring:
             testWhileIdle: true
             testOnBorrow: false
             testOnReturn: false
-            webStatFilter: 
+            webStatFilter:
                 enabled: true
             statViewServlet:
                 enabled: true

+ 107 - 0
ruoyi-admin/src/main/resources/application-test.yml

@@ -0,0 +1,107 @@
+# 项目相关配置
+ruoyi:
+    # 名称
+    name: 统一认证平台
+    # 版本
+    version: 4.7.5
+    # 版权年份
+    copyrightYear: 2022
+    # 实例演示开关
+    demoEnabled: false
+    # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
+#    profile: D:/ruoyi/uploadPath
+#    profile: /home/ruoyi/uploadPath
+#    profile: D:/工作文档/武汉三环科普睿科/Project/JavaProject\RuoYi
+    profile: ./
+
+
+    # 获取ip地址开关
+    addressEnabled: false
+
+# 开发环境配置
+server:
+    # 服务器的HTTP端口,默认为80
+#    port: 8082
+    port: 8301
+
+    servlet:
+        # 应用的访问路径
+        context-path: /
+    tomcat:
+        # tomcat的URI编码
+        uri-encoding: UTF-8
+        # 连接数满后的排队数,默认为100
+        accept-count: 1000
+        threads:
+            # tomcat最大线程数,默认为200
+            max: 800
+            # Tomcat启动初始化的线程数,默认值10
+            min-spare: 100
+# 数据源配置
+spring:
+    # 模板引擎
+    thymeleaf:
+        mode: HTML
+        encoding: utf-8
+        # 禁用缓存
+        cache: false
+    #数据库配置
+    datasource:
+            type: com.zaxxer.hikari.HikariDataSource
+            driverClassName: org.postgresql.Driver
+            druid:
+                # 主库数据源 stringtype=unspecified 如果stringtype设置为 unspecified,参数将作为非类型值发送到服务器,并且服务器将尝试推断适当的类型。
+                master:
+                     url: jdbc:postgresql://119.96.165.176:5432/test_lixing?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&useGeneratedKeys=true
+                     username: postgres
+                     password: kpr.23417.postgres
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: ruoyi
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+    devtools:
+        restart:
+          # 热部署开关
+          enabled: true

+ 4 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -29,7 +29,8 @@ spring:
     date-format: yyyy-MM-dd HH:mm:ss
   profiles: 
 #    active: druid
-    active: dev
+#    active: dev
+    active: test
 
   # 文件上传
   servlet:
@@ -52,6 +53,8 @@ mybatis:
     mapperLocations: classpath*:mapper/**/*Mapper.xml
     # 加载全局的配置文件
     configLocation: classpath:mybatis/mybatis-config.xml
+    #下划线转驼峰
+    map-underscore-to-camel-case: true
 
 # PageHelper分页插件
 pagehelper: 

+ 1 - 1
ruoyi-admin/src/main/resources/templates/main.html

@@ -28,7 +28,7 @@
 						<div class="float-e-margins" style="text-align: center;border: none">
 							<div     >
 								<!--<input type="text" th:value="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort()}">-->
-								<button class="btn btn-primary dim" type="button" th:style="'background:url(' +${dangan.dangan.iconInfo}+') no-repeat center center;width:50px;height:50px;background-size:100% 100%'" th:onclick="opennewpage([[${dangan.danganUrl}]] ,[[${dangan.danganNums} ]]);">
+								<button class="btn btn-primary dim" type="button" th:style="'background:url(' +${dangan.dangan==null?'':dangan.dangan.iconInfo}+') no-repeat center center;width:50px;height:50px;background-size:100% 100%'" th:onclick="opennewpage([[${dangan.danganUrl}]] ,[[${dangan.danganNums} ]]);">
 								</button>
 								<h3 class="no-margins" style="color:#1e9fff" th:text="${dangan.danganName}"></h3>
 								<h4 th:text="${@dict.getLabel('sys_dangan_status', dangan.danganStatus)}" ></h4><br>

+ 4 - 4
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java

@@ -31,7 +31,7 @@ public class SysRole extends BaseEntity
 
     /** 角色排序 */
     @Excel(name = "角色排序", cellType = ColumnType.NUMERIC)
-    private String roleSort;
+    private Integer roleSort;
 
     /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
     @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
@@ -120,13 +120,13 @@ public class SysRole extends BaseEntity
         this.roleKey = roleKey;
     }
 
-    @NotBlank(message = "显示顺序不能为空")
-    public String getRoleSort()
+//    @NotBlank(message = "显示顺序不能为空")
+    public Integer getRoleSort()
     {
         return roleSort;
     }
 
-    public void setRoleSort(String roleSort)
+    public void setRoleSort(Integer roleSort)
     {
         this.roleSort = roleSort;
     }

+ 5 - 2
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java

@@ -120,8 +120,11 @@ public class DataScopeAspect
             }
             else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
             {
-                sqlString.append(StringUtils.format(
-                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
+//                sqlString.append(StringUtils.format(
+//                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
+//                        deptAlias, user.getDeptId(), user.getDeptId()));
+                  sqlString.append(StringUtils.format(
+                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or {} = ANY (string_to_array(ancestors, ','))",
                         deptAlias, user.getDeptId(), user.getDeptId()));
             }
             else if (DATA_SCOPE_SELF.equals(dataScope))

+ 2 - 2
ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="dictType != null and dictType != ''">#{dictType},</if>
 			<if test="sort != null">#{sort},</if>
 			<if test="createBy != null and createBy != ''">#{createBy},</if>
-			sysdate()
+            now()
          )
     </insert>
 	 
@@ -105,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             dict_type = #{dictType},
             sort = #{sort},
             update_by = #{updateBy},
-            update_time = sysdate()
+            update_time = now()
         </set>
         where column_id = #{columnId}
     </update>

+ 2 - 2
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="genPath != null and genPath != ''">#{genPath},</if>
 			<if test="remark != null and remark != ''">#{remark},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
-			sysdate()
+			now()
          )
     </insert>
 
@@ -179,7 +179,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="options != null and options != ''">options = #{options},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             <if test="remark != null">remark = #{remark},</if>
-            update_time = sysdate()
+            update_time = now()
         </set>
         where table_id = #{tableId}
     </update>

+ 3 - 3
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml

@@ -36,10 +36,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 				AND invoke_target like concat('%', #{invokeTarget}, '%')
 			</if>
 			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
+				and to_date(create_time,'YY-MM-DD') &gt;= to_date(#{params.beginTime},'YY-MM-DD')
 			</if>
 			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+				and to_date(create_time,'YY-MM-DD') &lt;= to_date(#{params.endTime},'YY-MM-DD')
 			</if>
 		</where>
 	</select>
@@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
- 			sysdate()
+			now()
  		)
 	</insert>
 

+ 2 - 2
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml

@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status !=null">status = #{status},</if>
  			<if test="remark != null and remark != ''">remark = #{remark},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- 			update_time = sysdate()
+ 			update_time = now()
  		</set>
  		where job_id = #{jobId}
 	</update>
@@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
- 			sysdate()
+			now()
  		)
 	</insert>
 

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<id     property="roleId"       column="role_id"        />
 		<result property="roleName"     column="role_name"      />
 		<result property="roleKey"      column="role_key"       />
-		<result property="roleSort"     column="role_sort"      />
+		<result property="roleSort"     column="role_sort"   javaType="java.lang.Integer" jdbcType="INTEGER"   />
 		<result property="dataScope"    column="data_scope"     />
 		<result property="status"       column="status"         />
 		<result property="delFlag"      column="del_flag"       />