From 6af2bddf715b801ad3ae03a9eff823c069300915 Mon Sep 17 00:00:00 2001 From: "yuhang2.zhang" Date: Fri, 1 Nov 2024 20:14:20 +0800 Subject: [PATCH] [Bug] [dinky-admin] Fix the issue of primary key generation strategy causing negative primary keys. --- dinky-admin/src/main/java/org/dinky/data/model/Resources.java | 2 +- .../org/dinky/service/resource/impl/ResourceServiceImpl.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/model/Resources.java b/dinky-admin/src/main/java/org/dinky/data/model/Resources.java index 5a00c3032e..ecbc133b4a 100644 --- a/dinky-admin/src/main/java/org/dinky/data/model/Resources.java +++ b/dinky-admin/src/main/java/org/dinky/data/model/Resources.java @@ -54,7 +54,7 @@ @AllArgsConstructor public class Resources extends Model { - @TableId(type = IdType.ASSIGN_ID) + @TableId(type = IdType.AUTO) @ApiModelProperty(value = "ID", dataType = "Integer", example = "1", notes = "Unique identifier for the resource") private Integer id; diff --git a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java index e10c1ec7c4..5f9b5db87f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java @@ -86,6 +86,8 @@ public boolean syncRemoteDirectoryStructure() { x.setType(resources.getType()); x.setUserId(resources.getUserId()); } + x.setId(Math.abs(x.getId())); + x.setPid(Math.abs(x.getPid())); }) .collect(Collectors.toList()); // not delete root directory