xiaoyong931011
2023-08-16 5e9a1a931194b0d9eba759774dcad39fef1dba0b
src/main/java/cc/mrbird/febs/dapp/service/impl/AdminMallGoodsService.java
@@ -44,6 +44,7 @@
    private final MallGoodsCategoryMapper mallGoodsCategoryMapper;
    private final PlatformBannerMapper platformBannerMapper;
    private final MallGoodsImagesMapper mallGoodsImagesMapper;
    @Override
    public IPage<MallGoods> getCategoryListInPage(MallGoods mallGoods, QueryRequest request) {
@@ -70,6 +71,22 @@
        BeanUtil.copyProperties(addMallGoodsDto, mallGoods);
        mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED);
        mallGoodsMapper.insert(mallGoods);
        String thumbs = addMallGoodsDto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> imgs = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(imgs)) {
                int i = 1;
                for (String img : imgs) {
                    MallGoodsImages mallGoodsImages = new MallGoodsImages();
                    mallGoodsImages.setGoodsId(mallGoods.getId());
                    mallGoodsImages.setImageUrl(img);
                    mallGoodsImages.setSeq(i);
                    mallGoodsImagesMapper.insert(mallGoodsImages);
                    i++;
                }
            }
        }
        return new FebsResponse().success().message("操作成功");
    }
@@ -114,6 +131,8 @@
    @Override
    public MallGoods selectGoodsById(long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        List<String> thumbs = mallGoodsImagesMapper.selectByGoodId(mallGoods.getId());
        mallGoods.setImages(thumbs);
        return mallGoods;
    }
@@ -137,6 +156,23 @@
        BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods);
        mallGoodsMapper.updateById(mallGoods);
        mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId());
        String thumbs = mallGoodsUpdateDto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> imgs = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(imgs)) {
                int i = 1;
                for (String img : imgs) {
                    MallGoodsImages mallGoodsImages = new MallGoodsImages();
                    mallGoodsImages.setGoodsId(mallGoods.getId());
                    mallGoodsImages.setImageUrl(img);
                    mallGoodsImages.setSeq(i);
                    mallGoodsImagesMapper.insert(mallGoodsImages);
                    i++;
                }
            }
        }
        return new FebsResponse().success().message("操作成功");
    }