Procházet zdrojové kódy

update 优化代码生成中的Lock4j锁

AprilWind před 7 měsíci
rodič
revize
4bd3467595

+ 5 - 3
ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/controller/GenController.java

@@ -91,10 +91,12 @@ public class GenController extends BaseController {
      * 导入表结构(保存)
      *
      * @param tables 表名串
+     * @param dataName 数据源名称
      */
-    @RepeatSubmit()
     @SaCheckPermission("tool:gen:import")
     @Log(title = "代码生成", businessType = BusinessType.IMPORT)
+    @Lock4j(keys = {"#dataName"}, acquireTimeout = 10000)
+    @RepeatSubmit()
     @PostMapping("/importTable")
     public R<Void> importTableSave(String tables, String dataName) {
         String[] tableNames = Convert.toStrArray(tables);
@@ -107,9 +109,9 @@ public class GenController extends BaseController {
     /**
      * 修改保存代码生成业务
      */
-    @RepeatSubmit()
     @SaCheckPermission("tool:gen:edit")
     @Log(title = "代码生成", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
     @PutMapping
     public R<Void> editSave(@Validated @RequestBody GenTable genTable) {
         genTableService.validateEdit(genTable);
@@ -175,7 +177,7 @@ public class GenController extends BaseController {
      */
     @SaCheckPermission("tool:gen:edit")
     @Log(title = "代码生成", businessType = BusinessType.UPDATE)
-    @Lock4j
+    @Lock4j(keys = {"#tableId"}, acquireTimeout = 5000)
     @GetMapping("/synchDb/{tableId}")
     public R<Void> synchDb(@PathVariable("tableId") Long tableId) {
         genTableService.synchDb(tableId);