Преглед изворни кода

- 初始化日志:不在开发期间记录日志
- 定制生成器的一些配置

Huanyi пре 2 месеци
родитељ
комит
3ec82bfa1c

+ 2 - 0
pom.xml

@@ -75,6 +75,8 @@
                 <nacos.password>nacos</nacos.password>
                 <nacos.discovery.address>192.168.1.118</nacos.discovery.address>
                 <logstash.address>127.0.0.1:4560</logstash.address>
+                <seata.log>logback-spring-without-file.xml</seata.log>
+                <snailjob.log>logback-plus-without-file.xml</snailjob.log>
             </properties>
             <activation>
                 <!-- 默认环境 -->

+ 6 - 4
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java

@@ -18,10 +18,12 @@ public enum UserType {
      */
     SYS_USER("sys_user"),
 
-    /**
-     * 移动客户端用户
-     */
-    APP_USER("app_user");
+//    /**
+//     * 移动客户端用户
+//     */
+//    APP_USER("app_user"),
+
+    ;
 
     /**
      * 用户类型标识(用于 token、权限识别等)

+ 6 - 0
ruoyi-common/ruoyi-common-mybatis/src/main/java/com/yingpaipay/common/mybatis/utils/WrapperUtils.java

@@ -2,6 +2,12 @@ package com.yingpaipay.common.mybatis.utils;
 
 import java.util.List;
 
+/**
+ * 用于 {@code LambdaWrapper} 的增强工具类。
+ * @Author Huanyi
+ * @CreateTime 2026/02/07
+ */
+
 public class WrapperUtils {
 
     public static final List<Long> EMPTY_IDS = List.of(-1L);

+ 6 - 6
ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/core/service/SaPermissionImpl.java

@@ -37,9 +37,9 @@ public class SaPermissionImpl implements StpInterface {
             }
         }
         UserType userType = UserType.getUserType(loginUser.getUserType());
-        if (userType == UserType.APP_USER) {
-            // 其他端 自行根据业务编写
-        }
+//        if (userType == UserType.APP_USER) {
+//            // 其他端 自行根据业务编写
+//        }
         if (CollUtil.isNotEmpty(loginUser.getMenuPermission())) {
             // SYS_USER 默认返回权限
             return new ArrayList<>(loginUser.getMenuPermission());
@@ -64,9 +64,9 @@ public class SaPermissionImpl implements StpInterface {
             }
         }
         UserType userType = UserType.getUserType(loginUser.getUserType());
-        if (userType == UserType.APP_USER) {
-            // 其他端 自行根据业务编写
-        }
+//        if (userType == UserType.APP_USER) {
+//            // 其他端 自行根据业务编写
+//        }
         if (CollUtil.isNotEmpty(loginUser.getRolePermission())) {
             // SYS_USER 默认返回权限
             return new ArrayList<>(loginUser.getRolePermission());

+ 4 - 0
ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/constant/GenConstants.java

@@ -58,6 +58,10 @@ public interface GenConstants {
     String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp", "year", "interval",
         "smalldatetime", "datetime2", "datetimeoffset", "timestamptz"};
 
+    String[] COLOMNTYPE_DECIMAL = {"decimal"};
+
+    String[] COLOMNTYPE_INTEGER = {"tinyint", "smallint", "mediumint", "int", "int2", "int4", "int8", "number", "integer"};
+
     /**
      * 数据库数字类型
      */

+ 8 - 0
ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/util/GenUtils.java

@@ -57,6 +57,14 @@ public class GenUtils {
         } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
             column.setJavaType(GenConstants.TYPE_DATE);
             column.setHtmlType(GenConstants.HTML_DATETIME);
+
+            // 新增将 BigDecimal 和 Integer 补全
+        } else if (arraysContains(GenConstants.COLOMNTYPE_DECIMAL, dataType)) {
+            column.setHtmlType(GenConstants.HTML_INPUT);
+            column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
+        } else if (arraysContains(GenConstants.COLOMNTYPE_INTEGER, dataType)) {
+            column.setHtmlType(GenConstants.HTML_INPUT);
+            column.setJavaType(GenConstants.TYPE_INTEGER);
         } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
             column.setHtmlType(GenConstants.HTML_INPUT);
             // 数据库的数字字段与java不匹配 且很多数据库的数字字段很模糊 例如oracle只有number没有细分

+ 1 - 1
ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/serviceImpl.java.vm

@@ -99,7 +99,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
 #end
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
 #if($column.isPk==1)
-        lqw.orderByAsc(${ClassName}::get$AttrName);
+        lqw.orderByDesc(${ClassName}::get$AttrName);
 #end
 #end
         return lqw;

+ 42 - 41
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java

@@ -173,47 +173,48 @@ public class SysTenantServiceImpl implements ISysTenantService {
         userRole.setRoleId(roleId);
         userRoleMapper.insert(userRole);
 
-        String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
-        List<SysDictType> dictTypeList = dictTypeMapper.selectList(
-            new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId));
-        List<SysDictData> dictDataList = dictDataMapper.selectList(
-            new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId));
-        for (SysDictType dictType : dictTypeList) {
-            dictType.setDictId(null);
-            dictType.setTenantId(tenantId);
-            dictType.setCreateDept(null);
-            dictType.setCreateBy(null);
-            dictType.setCreateTime(null);
-            dictType.setUpdateBy(null);
-            dictType.setUpdateTime(null);
-        }
-        for (SysDictData dictData : dictDataList) {
-            dictData.setDictCode(null);
-            dictData.setTenantId(tenantId);
-            dictData.setCreateDept(null);
-            dictData.setCreateBy(null);
-            dictData.setCreateTime(null);
-            dictData.setUpdateBy(null);
-            dictData.setUpdateTime(null);
-        }
-        dictTypeMapper.insertBatch(dictTypeList);
-        dictDataMapper.insertBatch(dictDataList);
-
-        List<SysConfig> sysConfigList = configMapper.selectList(
-            new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId));
-        for (SysConfig config : sysConfigList) {
-            config.setConfigId(null);
-            config.setTenantId(tenantId);
-            config.setCreateDept(null);
-            config.setCreateBy(null);
-            config.setCreateTime(null);
-            config.setUpdateBy(null);
-            config.setUpdateTime(null);
-        }
-        configMapper.insertBatch(sysConfigList);
-
-        // 新增租户流程定义
-        remoteWorkflowService.syncDef(tenantId);
+        // TODO 暂定 菜单、系统配置 不进行租户隔离
+//        String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
+//        List<SysDictType> dictTypeList = dictTypeMapper.selectList(
+//            new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId));
+//        List<SysDictData> dictDataList = dictDataMapper.selectList(
+//            new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId));
+//        for (SysDictType dictType : dictTypeList) {
+//            dictType.setDictId(null);
+//            dictType.setTenantId(tenantId);
+//            dictType.setCreateDept(null);
+//            dictType.setCreateBy(null);
+//            dictType.setCreateTime(null);
+//            dictType.setUpdateBy(null);
+//            dictType.setUpdateTime(null);
+//        }
+//        for (SysDictData dictData : dictDataList) {
+//            dictData.setDictCode(null);
+//            dictData.setTenantId(tenantId);
+//            dictData.setCreateDept(null);
+//            dictData.setCreateBy(null);
+//            dictData.setCreateTime(null);
+//            dictData.setUpdateBy(null);
+//            dictData.setUpdateTime(null);
+//        }
+//        dictTypeMapper.insertBatch(dictTypeList);
+//        dictDataMapper.insertBatch(dictDataList);
+//
+//        List<SysConfig> sysConfigList = configMapper.selectList(
+//            new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId));
+//        for (SysConfig config : sysConfigList) {
+//            config.setConfigId(null);
+//            config.setTenantId(tenantId);
+//            config.setCreateDept(null);
+//            config.setCreateBy(null);
+//            config.setCreateTime(null);
+//            config.setUpdateBy(null);
+//            config.setUpdateTime(null);
+//        }
+//        configMapper.insertBatch(sysConfigList);
+//
+//        // 新增租户流程定义
+//        remoteWorkflowService.syncDef(tenantId);
         return true;
     }
 

+ 1 - 1
ruoyi-visual/ruoyi-seata-server/src/main/resources/application.yml

@@ -11,7 +11,7 @@ spring:
     active: @profiles.active@
 
 logging:
-  config: classpath:logback-spring.xml
+  config: classpath:@seata.log@
   file:
     path: ./logs/seata
 #  extend:

+ 49 - 0
ruoyi-visual/ruoyi-seata-server/src/main/resources/logback-spring-with-file.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Copyright 1999-2019 Seata.io Group.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- Context listeners -->
+    <contextListener class="org.apache.seata.server.logging.listener.SystemPropertyLoggerContextListener"/>
+    <!-- common properties -->
+    <springProperty name="PORT" source="server.port" defaultValue="7091"/>
+    <springProperty name="APPLICATION_NAME" source="spring.application.name" defaultValue="seata-server"/>
+
+    <!-- 日志存放路径 -->
+    <property name="log.path" value="logs/${project.artifactId}"/>
+    <!-- 日志输出格式 -->
+    <property name="console.log.pattern"
+              value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${console.log.pattern}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+    </appender>
+
+    <include resource="logback-common.xml" />
+
+    <include resource="logback-logstash.xml" />
+
+    <!-- 开启 skywalking 日志收集 -->
+    <include resource="logback-skylog.xml" />
+
+    <root level="INFO">
+        <appender-ref ref="console"/>
+    </root>
+</configuration>

+ 49 - 0
ruoyi-visual/ruoyi-seata-server/src/main/resources/logback-spring-without-file.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Copyright 1999-2019 Seata.io Group.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- Context listeners -->
+    <contextListener class="org.apache.seata.server.logging.listener.SystemPropertyLoggerContextListener"/>
+    <!-- common properties -->
+    <springProperty name="PORT" source="server.port" defaultValue="7091"/>
+    <springProperty name="APPLICATION_NAME" source="spring.application.name" defaultValue="seata-server"/>
+
+    <!-- 日志存放路径 -->
+<!--    <property name="log.path" value="logs/${project.artifactId}"/>-->
+    <!-- 日志输出格式 -->
+    <property name="console.log.pattern"
+              value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${console.log.pattern}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+    </appender>
+
+<!--    <include resource="logback-common.xml" />-->
+
+    <include resource="logback-logstash.xml" />
+
+    <!-- 开启 skywalking 日志收集 -->
+    <include resource="logback-skylog.xml" />
+
+    <root level="INFO">
+        <appender-ref ref="console"/>
+    </root>
+</configuration>

+ 1 - 1
ruoyi-visual/ruoyi-snailjob-server/src/main/resources/application.yml

@@ -25,7 +25,7 @@ mybatis-plus:
     cache-enabled: true
 
 logging:
-  config: classpath:logback-plus.xml
+  config: classpath:@snailjob.log@
 
 management:
   endpoints:

+ 25 - 0
ruoyi-visual/ruoyi-snailjob-server/src/main/resources/logback-plus-with-file.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 日志存放路径 -->
+    <property name="log.path" value="logs/${project.artifactId}"/>
+    <!-- 日志输出格式 -->
+    <property name="console.log.pattern"
+              value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${console.log.pattern}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+    </appender>
+
+    <include resource="logback-common.xml" />
+
+    <include resource="logback-logstash.xml" />
+
+    <!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="console"/>
+    </root>
+</configuration>

+ 25 - 0
ruoyi-visual/ruoyi-snailjob-server/src/main/resources/logback-plus-without-file.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 日志存放路径 -->
+<!--    <property name="log.path" value="logs/${project.artifactId}"/>-->
+    <!-- 日志输出格式 -->
+    <property name="console.log.pattern"
+              value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${console.log.pattern}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+    </appender>
+
+<!--    <include resource="logback-common.xml" />-->
+
+    <include resource="logback-logstash.xml" />
+
+    <!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="console"/>
+    </root>
+</configuration>