From 81aacc9579580351898c5c2f673bcf3f7f0ec8df Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 07 八月 2025 19:10:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 framework/src/main/java/cn/lili/modules/lmk/service/impl/GoodsBannerServiceImpl.java |  143 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 143 insertions(+), 0 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/GoodsBannerServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/GoodsBannerServiceImpl.java
new file mode 100644
index 0000000..82d1d37
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/GoodsBannerServiceImpl.java
@@ -0,0 +1,143 @@
+package cn.lili.modules.lmk.service.impl;
+
+import cn.lili.common.utils.StringUtils;
+import cn.lili.utils.COSUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import cn.lili.modules.lmk.domain.entity.GoodsBanner;
+import cn.lili.modules.lmk.mapper.GoodsBannerMapper;
+import cn.lili.modules.lmk.service.GoodsBannerService;
+import cn.lili.base.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import cn.lili.modules.lmk.domain.form.GoodsBannerForm;
+import cn.lili.modules.lmk.domain.vo.GoodsBannerVO;
+import cn.lili.modules.lmk.domain.query.GoodsBannerQuery;
+import org.springframework.stereotype.Service;
+import lombok.RequiredArgsConstructor;
+import cn.lili.utils.PageUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.Assert;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 鍟嗗搧骞垮満鎺ㄨ崘 鏈嶅姟瀹炵幇绫�
+ *
+ * @author peng
+ * @since 2025-08-07
+ */
+@Service
+@RequiredArgsConstructor
+public class GoodsBannerServiceImpl extends ServiceImpl<GoodsBannerMapper, GoodsBanner> implements GoodsBannerService {
+
+    private final GoodsBannerMapper goodsBannerMapper;
+    private final COSUtil cosUtil;
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    @Override
+    public Result add(GoodsBannerForm form) {
+        GoodsBanner entity = GoodsBannerForm.getEntityByForm(form, null);
+        baseMapper.insert(entity);
+        return Result.ok("娣诲姞鎴愬姛");
+    }
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    @Override
+    public Result update(GoodsBannerForm form) {
+        GoodsBanner entity = baseMapper.selectById(form.getId());
+
+        // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
+        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+        BeanUtils.copyProperties(form, entity);
+        baseMapper.updateById(entity);
+        return Result.ok("淇敼鎴愬姛");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @Override
+    public Result remove(List<String> ids) {
+        baseMapper.deleteBatchIds(ids);
+        return Result.ok("鍒犻櫎鎴愬姛");
+    }
+
+    /**
+     * id鍒犻櫎
+     * @param id
+     * @return
+     */
+    @Override
+    public Result removeById(String id) {
+        baseMapper.deleteById(id);
+        return Result.ok("鍒犻櫎鎴愬姛");
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param query
+     * @return
+     */
+    @Override
+    public Result page(GoodsBannerQuery query) {
+        IPage<GoodsBannerVO> page = PageUtil.getPage(query, GoodsBannerVO.class);
+        baseMapper.getPage(page, query);
+        page.getRecords().stream().forEach(item -> {
+            String bannerUrl = item.getBannerUrl();
+            if (StringUtils.isNotEmpty(bannerUrl)&&!bannerUrl.contains("http")) {
+                item.setShowBannerUrl(cosUtil.getPreviewUrl(bannerUrl));
+            }else {
+                item.setShowBannerUrl(bannerUrl);
+            }
+        });
+        return Result.ok().data(page.getRecords()).total(page.getTotal());
+    }
+
+    @Override
+    public Result getBannerList(GoodsBannerQuery query) {
+        List<GoodsBannerVO> bannerList = baseMapper.getBannerList(query);
+        bannerList.forEach(item -> {
+            String bannerUrl = item.getBannerUrl();
+            if (StringUtils.isNotEmpty(bannerUrl)&&!bannerUrl.contains("http")) {
+                item.setShowBannerUrl(cosUtil.getPreviewUrl(bannerUrl));
+            }else {
+                item.setShowBannerUrl(bannerUrl);
+            }
+        });
+        return Result.ok().data(bannerList);
+    }
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    @Override
+    public Result detail(String id) {
+        GoodsBannerVO vo = baseMapper.getById(id);
+        Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+        return Result.ok().data(vo);
+    }
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    @Override
+    public Result all() {
+        List<GoodsBanner> entities = baseMapper.selectList(null);
+        List<GoodsBannerVO> vos = entities.stream()
+                .map(entity -> GoodsBannerVO.getVoByEntity(entity, null))
+                .collect(Collectors.toList());
+        return Result.ok().data(vos);
+    }
+}

--
Gitblit v1.8.0