Selaa lähdekoodia

修复代码生成导入表结构出现异常页面不提醒问题

RuoYi 5 vuotta sitten
vanhempi
commit
0788a57bec

+ 8 - 7
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java

@@ -23,6 +23,7 @@ import com.ruoyi.common.core.constant.Constants;
23 23
 import com.ruoyi.common.core.constant.GenConstants;
24 24
 import com.ruoyi.common.core.exception.CustomException;
25 25
 import com.ruoyi.common.core.utils.StringUtils;
26
+import com.ruoyi.common.security.utils.SecurityUtils;
26 27
 import com.ruoyi.gen.domain.GenTable;
27 28
 import com.ruoyi.gen.domain.GenTableColumn;
28 29
 import com.ruoyi.gen.mapper.GenTableColumnMapper;
@@ -142,10 +143,10 @@ public class GenTableServiceImpl implements IGenTableService
142 143
     @Transactional
143 144
     public void importGenTable(List<GenTable> tableList)
144 145
     {
145
-        String operName = "";
146
-        for (GenTable table : tableList)
146
+        String operName = SecurityUtils.getUsername();
147
+        try
147 148
         {
148
-            try
149
+            for (GenTable table : tableList)
149 150
             {
150 151
                 String tableName = table.getTableName();
151 152
                 GenUtils.initTable(table, operName);
@@ -161,10 +162,10 @@ public class GenTableServiceImpl implements IGenTableService
161 162
                     }
162 163
                 }
163 164
             }
164
-            catch (Exception e)
165
-            {
166
-                log.error("表名 " + table.getTableName() + " 导入失败:", e);
167
-            }
165
+        }
166
+        catch (Exception e)
167
+        {
168
+            throw new CustomException("导入失败:" + e.getMessage());
168 169
         }
169 170
     }
170 171