From e39d3707139947dcdfddc995e10a05e8824134b0 Mon Sep 17 00:00:00 2001 From: YenHex Date: Fri, 8 Sep 2023 17:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5id=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsl/service/impl/GoodsServiceImpl.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java b/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java index 4c1287b..e29fe24 100644 --- a/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java +++ b/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java @@ -28,7 +28,11 @@ public class GoodsServiceImpl implements GoodsService { final String sqlCountJslSpecValue = "SELECT `id` FROM `goods_spec_value` where spec_id=? and name=?"; public DbContext getJslDbContext() { - return new DbContext("test", "jdbc:mysql://192.168.0.9:3306/jsl_mall_qs_dev2?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", "kpjsl", "123456"); + return new DbContext("pro", + "jdbc:mysql://183.56.249.148/jsl_cost_base?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", + "root", + "@Jsl2282125"); + //return new DbContext("test", "jdbc:mysql://192.168.0.9:3306/jsl_mall_qs_dev2?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", "kpjsl", "123456"); } public DbContext getXltDbContext() { @@ -230,10 +234,8 @@ public class GoodsServiceImpl implements GoodsService { if (spuId == null) { //加载销路通spu XltSpu xltSpu = xltDb.sql(sql4XltSpu, xltGoods.getSpuId()).getItem(XltSpu.class); - spuId = StringUtils.genShortLong(); String xltSpuId = xltSpu.getId(); JslGoodSpu goodSpu = new JslGoodSpu(); - goodSpu.setId(spuId); goodSpu.setSpuCode(xltSpu.getCode()); goodSpu.setName(xltSpu.getName()); goodSpu.setTasteValue(tasteSku); @@ -264,11 +266,13 @@ public class GoodsServiceImpl implements GoodsService { } //保存spu - jslDb.table("goods_spu").setEntity(goodSpu).insert(); + System.out.println("新增spu:"+goodSpu.getSpuCode()); + spuId = jslDb.table("goods_spu").setEntity(goodSpu).insert(); + goodSpu.setId(spuId); } //保存sku JslGoodsSku goodsSku = new JslGoodsSku(); - goodsSku.setId(StringUtils.genShortLong()); + //goodsSku.setId(StringUtils.genShortLong()); goodsSku.setSkuCode(xltGoods.getCode()); goodsSku.setSpuId(spuId); goodsSku.setPicUrl(""); @@ -280,7 +284,9 @@ public class GoodsServiceImpl implements GoodsService { goodsSku.setCostFlag(1); goodsSku.setEnable(shelf); goodsSku.setTenantId(TENANT_ID); - jslDb.table("goods_sku").setEntity(goodsSku).insert(); + System.out.println("新增SKU:"+goodsSku.getSkuCode()); + Long skuId = jslDb.table("goods_sku").setEntity(goodsSku).insert(); + goodsSku.setId(skuId); //保存spec List specValueIds = new ArrayList<>(); specValueIds.add(initSpecValue(jslDb, 3L, address)); @@ -366,13 +372,10 @@ public class GoodsServiceImpl implements GoodsService { Long specValueId = jslDb.sql(sqlCountJslSpecValue, specId, specValueName).getDataItem().getLong("id"); if (specValueId == null) { JslGoodSpecValue specValue = new JslGoodSpecValue(); - specValueId = StringUtils.genShortLong(); - specValue.setId(specValueId); specValue.setTenantId("001"); specValue.setSpecId(specId); specValue.setName(specValueName); - jslDb.table("goods_spec_value").setEntity(specValue).insert(); - return specValueId; + return jslDb.table("goods_spec_value").setEntity(specValue).insert(); } return specValueId; }