From a3601b9d46af0103c866f1a084919f34e8c6768d Mon Sep 17 00:00:00 2001 From: ruying408 <1877972603@qq.com> Date: Fri, 30 Aug 2024 22:41:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20json=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/cool/core/init/DBFromJsonInit.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cool/core/init/DBFromJsonInit.java b/src/main/java/com/cool/core/init/DBFromJsonInit.java index 0d8ef76..fc29c9a 100644 --- a/src/main/java/com/cool/core/init/DBFromJsonInit.java +++ b/src/main/java/com/cool/core/init/DBFromJsonInit.java @@ -144,7 +144,12 @@ public class DBFromJsonInit implements ApplicationRunner { // 数据库已经有值了 continue; } - baseMapper.insertSelectiveWithPk(entity); + if (ObjUtil.isNotEmpty(id)) { + // 带id插入 + baseMapper.insertSelectiveWithPk(entity); + } else { + baseMapper.insert(entity); + } } }