商品模块代码提交

This commit is contained in:
Tankaikai 2025-02-17 10:18:19 +08:00
parent d22bbf41e3
commit 1daef6efba
1 changed files with 8 additions and 7 deletions

View File

@ -79,12 +79,12 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
ShopProdSpec entity = BeanUtil.copyProperties(dto, ShopProdSpec.class);
if (GlobalConstant.TREE_ROOT.equals(entity.getPid())) {
entity.setFullName(entity.getName());
entity.setPids(GlobalConstant.TREE_ROOT.toString());
entity.setPids(GlobalConstant.TREE_ROOT + ",");
} else {
ShopProdSpec parent = super.getById(entity.getPid());
entity.setFullName(parent.getFullName() + " - " + entity.getName());
String pids = parent.getPids();
entity.setPids(pids + "," + entity.getPid());
entity.setPids(pids + entity.getPid() + ",");
}
entity.setStatus(StatusEnum.ENABLED.value());
entity.setShopId(shopId);
@ -112,16 +112,17 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
ShopProdSpec entity = BeanUtil.copyProperties(dto, ShopProdSpec.class);
if (GlobalConstant.TREE_ROOT.equals(entity.getPid())) {
entity.setFullName(entity.getName());
entity.setPids(GlobalConstant.TREE_ROOT.toString());
entity.setPids(GlobalConstant.TREE_ROOT + ",");
} else {
ShopProdSpec parent = super.getById(entity.getPid());
entity.setFullName(parent.getFullName() + " - " + entity.getName());
String pids = parent.getPids();
entity.setPids(pids + "," + entity.getPid());
entity.setPids(pids + entity.getPid() + ",");
}
String oldName = old.getName();
UpdateChain.of(ShopProdSpec.class)
.setRaw(ShopProdSpec::getFullName, StrUtil.format("replace(full_name, '{}', '{}')", oldName, entity.getName()))
.like(ShopProdSpec::getPids, "," + entity.getId() + ",")
.eq(ShopProdSpec::getShopId, entity.getShopId()).update();
return super.updateById(entity);
}
@ -131,7 +132,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
Long shopId = StpKit.USER.getLoginIdAsLong();
return super.remove(query()
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id))))
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ","))))
);
}
@ -141,7 +142,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
return UpdateChain.of(ShopProdSpec.class)
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.DISABLE.value())
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id)))).update();
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ",")))).update();
}
@Override
@ -150,7 +151,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
return UpdateChain.of(ShopProdSpec.class)
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.ENABLED.value())
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id)))).update();
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ",")))).update();
}
}